home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d966.lha
/
UChessSrc
/
UChessSrc.lha
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-09
|
146KB
|
5,392 lines
/*#define EIGHT_BIT_SCREEN 1 */
/* main.c - C source for GNU CHESS
*
* Copyright (c) 1988,1989,1990 John Stanback
* Copyright (c) 1992 Free Software Foundation
*
* This file is part of GNU CHESS.
*
* GNU Chess is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* GNU Chess is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Chess; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
int __aligned CheckIllegal = 0;
extern int IllegalMove;
#include "version.h"
#include "gnuchess.h"
#include <signal.h>
#include <ctype.h>
#ifdef AMIGA
#define EXCLUDE_PATT 0xffffff00L
#define __USE_SYSBASE
#include <exec/types.h>
#include <exec/exec.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <graphics/gfxbase.h>
#include <proto/intuition.h>
#include <utility/tagitem.h>
#include <graphics/modeid.h>
#include <lhlib.h>
#include <libraries/asl.h>
#include <proto/icon.h>
#include <proto/asl.h>
#include <workbench/startup.h>
#include <workbench/workbench.h>
#define mySetABPenDrMd(a,b,c,d) if (gfxversion > 38) {SetABPenDrMd(a,b,c,d);} else {SetAPen(a,b);SetDrMd(a,d);}
struct __iobuf __iob[1];
#define LN2 693147 /* .693147 */
#define LOGE_34 3526361 /* log2(34) = ln(34)/ln(2) = 5.087463 */
#define LOGE_16 2772589 /* ln(16) = */
void calc_pgm_rating(void);
void DoEasy(void);
void DoIntermediate(void);
void DoAdvanced(void);
/* this table index ln(2)*1e6 - ln(1202)*1e6 by 6's */
/* so take (#secs - 2)/6 for index into this table */
long __aligned OrigResponse;
int __aligned __far log_e[]={
693147, 2079442, 2639057, 2995732, 3258097, 3465736, 3637586, 3784190,
3912023, 4025352, 4127134, 4219508, 4304065, 4382027, 4454347, 4521789,
4584967, 4644391, 4700480, 4753590, 4804021, 4852030, 4897840, 4941642,
4983607, 5023881, 5062595, 5099866, 5135798, 5170484, 5204007, 5236442,
5267858, 5298317, 5327876, 5356586, 5384495, 5411646, 5438079, 5463832,
5488938, 5513429, 5537334, 5560682, 5583496, 5605802, 5627621, 5648974,
5669881, 5690359, 5710427, 5730100, 5749393, 5768321, 5786897, 5805135,
5823046, 5840642, 5857933, 5874931, 5891644, 5908083, 5924256, 5940171,
5955837, 5971262, 5986452, 6001415, 6016157, 6030685, 6045005, 6059123,
6073045, 6086775, 6100319, 6113682, 6126869, 6139885, 6152733, 6165418,
6177944, 6190315, 6202536, 6214608, 6226537, 6238325, 6249975, 6261492,
6272877, 6284134, 6295266, 6306275, 6317165, 6327937, 6338594, 6349139,
6359574, 6369901, 6380123, 6390241, 6400257, 6410175, 6419995, 6429719,
6439350, 6448889, 6458338, 6467699, 6476972, 6486161, 6495266, 6504288,
6513230, 6522093, 6530878, 6539586, 6548219, 6556778, 6565265, 6573680,
6582025, 6590301, 6598509, 6606650, 6614726, 6622736, 6630683, 6638568,
6646391, 6654153, 6661855, 6669498, 6677083, 6684612, 6692084, 6699500,
6706862, 6714171, 6721426, 6728629, 6735780, 6742881, 6749931, 6756932,
6763885, 6770789, 6777647, 6784457, 6791221, 6797940, 6804615, 6811244,
6817831, 6824374, 6830874, 6837333, 6843750, 6850126, 6856462, 6862758,
6869014, 6875232, 6881411, 6887553, 6893656, 6899723, 6905753, 6911747,
6917706, 6923629, 6929517, 6935370, 6941190, 6946976, 6952729, 6958448,
6964136, 6969791, 6975414, 6981006, 6986566, 6992096, 6997596, 7003065,
7008505, 7013915, 7019297, 7024649, 7029973, 7035269, 7040536, 7045777,
7050989, 7056175, 7061334, 7066467, 7071573, 7076654, 7081709, 7086738,
7091742};
/* Structure for transparent images */
#define PTRHEIGHT 55
#define BLANKDATA 0xffff
int __aligned lastpiece=BLANKDATA;
void Undo(void);
char __aligned __far vstring[64]={AVSTR};
long __far __aligned piecechar[12]={'p','n','b','r','q','k',
'P','N','B','R','Q','K'};
char __far __aligned oldboard[8][8];
ULONG __far __aligned bpen;
int __aligned PlayMode = 2;
int __aligned global_tmp_score=0;
int __aligned previous_score=0;
extern short int ISZERO;
extern int thinkahead;
unsigned long int __aligned next = 1;
int __aligned doswap=0;
int __aligned doundo=0;
int __aligned doauto=0;
int __aligned gfxversion=0L;
int __aligned v15Khz=0L;
int __aligned teston=0;
struct TagItem __aligned __far myTagList[4] = {
{SA_DisplayID,VGAPRODUCT_KEY},
{0,0}
};
int __aligned MoveNowOK=0;
#define WINDOWSIGNAL (1L<<(wG->UserPort->mp_SigBit))
ULONG __aligned globalsignalset=0L;
int __aligned Super72=0;
int __aligned procpri=3;
struct Process __aligned *myproc;
int __aligned __far ResignOffered=0;
ULONG __far __aligned tmppal[4];
inline void TimeCalc (void);
int __far __aligned FasterDisplay=0;
int __aligned trying_again=0;
int __aligned SupervisorMode=0;
int __aligned MenuStripSet = 0;
int __aligned GlobalTgtDepth=3;
UWORD chip myPointer[]={
0,0,
31744,0,
4096,0,
4096,0,
4096,0,
4096,0,
5120,0,
5120,0,
1024,0,
1920,0,
1152,0,
1152,0,
1152,0,
256,0,
0,0,
768,0,
256,0,
256,0,
256,0,
896,0,
0,0,
896,0,
576,0,
576,0,
576,0,
576,0,
0,0,
512,0,
512,0,
576,0,
640,0,
896,0,
640,0,
576,0,
0,0,
256,0,
0,0,
768,0,
256,0,
256,0,
256,0,
896,0,
0,0,
0,0,
896,0,
576,0,
576,0,
576,0,
576,0,
0,0,
960,0,
576,0,
576,0,
960,0,
64,0,
960,0,
0,0
};
struct TransImage
{
struct Image *ti_IM; /* The plain image */
struct BitMap *ti_sBM; /* Shadow bitmap */
struct RastPort *ti_sRP; /* Shadow rastport */
struct BitMap ti_BM; /* Image bitmap */
struct RastPort ti_RP; /* Image rastport */
};
struct Image __aligned BobImage;
struct TransImage __aligned *BobTransImage;
struct TransImage *AllocTransImage (struct Image * im);
VOID FreeTransImage (struct TransImage * ti);
VOID ClipBlitTrans (struct RastPort *, WORD, WORD, struct RastPort *, WORD, WORD, WORD, WORD, struct RastPort *);
struct BitMap *AllocShadowBM (UWORD, UWORD, UWORD);
VOID FreeShadowBM (struct BitMap *);
struct RastPort *AllocShadowRP (struct BitMap *);
VOID FreeShadowRP (struct RastPort *);
long __aligned OrigCol,OrigRow,DestCol,DestRow;
#define TDEPTH 4
#define THEIGHT 400 /* tmp ht */
#define TBLOCKPEN 4 /* was 9 */
#ifdef EIGHT_BIT_SCREEN
int __aligned DEPTH=8;
#ifdef MANYP
int __aligned HEIGHT=480;
int __aligned USERBOX=168;
int __aligned COMPUTERBOX=60;
int __aligned BACKGNDTEXTCOLOR=0xe0; /* for 256 use 0xe0 */
int __aligned BOBHEIGHT=55; /* 55 for 480 screens */
int __aligned ROW8=24; /* 24 for 480 screens */
int __aligned MBLOCKPEN=251;
#endif
#else
int __aligned DEPTH=4;
#endif
int __aligned TCadd = 0;
int __aligned thinking2=0; /* look for move now menu selection in elasped time when set */
int __aligned TIMEYCOORD1=100;
int __aligned TIMEYCOORD2=192;
int __aligned SYSBOXLEN=86;
int __aligned HEIGHT=400;
int __aligned USERBOX=140;
int __aligned SYSTEMBOX=233;
int __aligned COMPUTERBOX=50;
int __aligned BACKGNDTEXTCOLOR=15; /* for 256 use 0xe0 */
int __aligned BOBHEIGHT=46; /* 55 for 480 screens */
int __aligned ROW8=20; /* 24 for 480 screens */
int __aligned MBLOCKPEN=9;
#define MENUBARHT 11
#define WIDTH 640
#define VIEWMODES (HIRES|LACE)
int __aligned BOBDEPTH=TDEPTH;
#define BOBWIDTH 64 /* only 59 pixels are really used, rest are tranparent */
#define BOBWIDINW 4
#define BOBSIZE (BOBHEIGHT*BOBDEPTH*BOBWIDINW*sizeof(WORD))
#define BOBBLOCKSIZE ((BOBSIZE)+(BOBWIDINW*sizeof(WORD)*(BOBHEIGHT+2))+(BOBWIDINW*sizeof(WORD)))
#define BOBLW ((BOBBLOCKSIZE)/4)
#define BOBMEMASK 0
#define BOBHITMASK 0
int __aligned BOBPLANEPICK=0xf; /* if 16 colors should be 0xf if 256 should be 0xff */
#define BOBPLANEONOFF 0x0
#define SQUAREWIDTH 59
#define ROUNDEDSQUAREWIDTH 64
#define SQUAREHEIGHT BOBHEIGHT
#define COLA (16)
#define COLB (16+SQUAREWIDTH)
#define COLC (16+SQUAREWIDTH*2)
#define COLD (16+SQUAREWIDTH*3)
#define COLE (16+SQUAREWIDTH*4)
#define COLF (16+SQUAREWIDTH*5)
#define COLG (16+SQUAREWIDTH*6)
#define COLH (16+SQUAREWIDTH*7)
#define ROW7 (ROW8+SQUAREHEIGHT)
#define ROW6 (ROW8+SQUAREHEIGHT*2)
#define ROW5 (ROW8+SQUAREHEIGHT*3)
#define ROW4 (ROW8+SQUAREHEIGHT*4)
#define ROW3 (ROW8+SQUAREHEIGHT*5)
#define ROW2 (ROW8+SQUAREHEIGHT*6)
#define ROW1 (ROW8+SQUAREHEIGHT*7)
UWORD __aligned *BlankImageData;
UWORD __far __aligned *WhiteImageData[6];
UWORD __far __aligned *BlackImageData[6];
void LoadBobImage(long);
long __far __aligned ColArray[8]={COLA,COLB,COLC,COLD,COLE,COLF,COLG,COLH};
long __far __aligned RowArray[8];
struct VSprite __aligned *SpriteHead;
struct VSprite __aligned *SpriteTail;
struct GelsInfo __aligned *myGelsInfo;
struct VSprite __aligned *BobVSprite;
struct Bob __aligned *TheBob;
struct BitMap __aligned *WhiteBitMap,*BlackBitMap;
struct TextFont __aligned *myTextFont;
extern struct GfxBase __aligned *Gfxbase;
long __aligned __stack=50000L;
ULONG tt;
struct RastPort __aligned *rpG;
struct ViewPort __aligned *vP;
struct Screen __aligned *sC;
struct Window __aligned *wG;
struct Window __aligned *wGEdit;
unsigned char __far __aligned cookedchar[128]={'~',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0', /* 10 */
'-',
'=',
' ',
' ',
'0',
'Q', /* 16 */
'W',
'E',
'R',
'T', /* 20 */
'Y',
'U',
'I',
'O',
'P', /* 25 */
'[',
']',
' ',
'1',
'2',
'3',
'A',
'S',
'D',
'F',
'G',
'H',
'J',
'K',
'L', /* 40 */
':',
'"',
13,
' ',
'4',
'5',
'6',
' ',
'Z',
'X', /* 50 */
'C',
'V',
'B',
'N',
'M', /* 55 */
',',
'.',
'/',
' ',
'.',
'7',
'8',
'9',
' ',
7,
8,
13,
13,
27,
7
};
char __aligned *Orig_PlanePtr;
struct BitMap __aligned *myBitMap;
#include "Chess256Palette.c"
UWORD __far __aligned myPalette[16]=
{
0xfbc, 0x632, 0x455, 0x842, 0x549, 0xa53, 0x787, 0xa56,
0x967, 0xa85, 0x3ab, 0xaaa, 0xe88, 0xdb8, 0x333, 0xeee
};
#ifdef OLDPAL
{
0x0, 0x222, 0x410, 0x333,
0x621, 0x624, 0x952, 0x665,
0x974, 0x887, 0xb85, 0xaa9,
0xbb7, 0xcc8, 0xcc9, 0xddc};
#endif
struct TextAttr __far __aligned TOPAZ80 = {
(STRPTR)"topaz.font",
TOPAZ_EIGHTY,0,0
};
SHORT __far __aligned BorderVectors6[] = {
0,0,
44,0,
44,19,
0,19,
0,0
};
struct Border __far __aligned Border6 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
BorderVectors6, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned IText93 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
12,6, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"OK", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned Gadget9 = {
NULL, /* next gadget */
109,64, /* origin XY of hit box relative to window TopLeft */
43,18, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&Border6, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&IText93, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
UBYTE __aligned Gadget8SIBuff[8];
struct StringInfo __aligned Gadget8SInfo = {
Gadget8SIBuff, /* buffer where text will be edited */
NULL, /* optional undo buffer */
0, /* character position in buffer */
5, /* maximum number of characters to allow */
0, /* first displayed character buffer position */
0,0,0,0,0, /* Intuition initialized and maintained variables */
0, /* Rastport of gadget */
0, /* initial value for integer gadgets */
NULL /* alternate keymap (fill in if you set the flag) */
};
SHORT __far __aligned BorderVectors7[] = {
0,0,
45,0 /* was 45 */,
45,14, /* was 17 */
0,14,
0,0
};
struct Border __far __aligned Border7 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
BorderVectors7, /* pointer to XY vectors */
NULL /* next border in list */
};
struct Gadget __far __aligned Gadget8 = {
&Gadget9, /* next gadget */
136,32, /* origin XY of hit box relative to window TopLeft */
44,16, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
STRGADGET, /* gadget type flags */
(APTR)&Border7, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Gadget8SInfo, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
UBYTE __aligned Gadget6SIBuff[8];
struct StringInfo __aligned Gadget6SInfo = {
Gadget6SIBuff, /* buffer where text will be edited */
NULL, /* optional undo buffer */
0, /* character position in buffer */
4, /* maximum number of characters to allow */
0, /* first displayed character buffer position */
0,0,0,0,0, /* Intuition initialized and maintained variables */
0, /* Rastport of gadget */
0, /* initial value for integer gadgets */
NULL /* alternate keymap (fill in if you set the flag) */
};
struct Border __far __aligned Border9 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
BorderVectors7, /* pointer to XY vectors */
NULL /* next border in list */
};
struct Gadget __far __aligned Gadget6 = {
&Gadget8, /* next gadget */
14,32, /* origin XY of hit box relative to window TopLeft */
44,16, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
STRGADGET, /* gadget type flags */
(APTR)&Border9, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Gadget6SInfo, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct Gadget __far __aligned Gadget6b = {
&Gadget9, /* next gadget */
14,32, /* origin XY of hit box relative to window TopLeft */
44,16, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
STRGADGET, /* gadget type flags */
(APTR)&Border9, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&Gadget6SInfo, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
/**/
struct IntuiText __aligned IText47 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
195,36, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Minutes.", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText __far __aligned IText46 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
64,35, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Moves in", /* pointer to text */
&IText47 /* next IntuiText structure */
};
#define IntuiTextList5 IText46
struct NewWindow __far __aligned NewWindowStructure5 = {
161,23, /* window XY origin relative to TopLeft of screen */
270,90, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
GADGETUP, /* IDCMP flags */
SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH, /* other window flags */
&Gadget6, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Computer Time Ctrl", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
struct ExtNewScreen __far __aligned NewScreenStructure = {
0,0, /* screen XY origin relative to View */
WIDTH,THEIGHT, /* screen width and height */
4, /* screen depth (number of bitplanes) */
0,TBLOCKPEN, /* detail and block pens */
VIEWMODES, /* display modes for this screen */
CUSTOMBITMAP|CUSTOMSCREEN, /* screen type */
&TOPAZ80, /* pointer to default screen font */
VERSTRING, /* screen title */
NULL, /* first in list of custom screen gadgets */
NULL /* pointer to custom BitMap structure */
};
struct ExtNewScreen __far __aligned NewScreenStructure2 = {
0,0, /* screen XY origin relative to View */
WIDTH,480, /* screen width and height */
8, /* screen depth (number of bitplanes) */
0,251, /* detail and block pens */
VIEWMODES, /* display modes for this screen */
CUSTOMSCREEN|SCREENBEHIND, /* screen type */
&TOPAZ80, /* pointer to default screen font */
" ", /* screen title */
NULL, /* first in list of custom screen gadgets */
NULL /* pointer to custom BitMap structure */
};
struct IntuiText __far __aligned IText37 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"New Game", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText __far __aligned IText1r = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Set Depth", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem3r = {
NULL, /* next MenuItem structure */
0,32, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText1r, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText1 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Set Time", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem3 = {
&MenuItem3r, /* next MenuItem structure */
0,24, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText1, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText2x = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Rate Pgm", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem3x = {
&MenuItem3, /* next MenuItem structure */
0,16, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText2x, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText2 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Test", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem2 = {
&MenuItem3x, /* next MenuItem structure */
0,8, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText2, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText3 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Hint", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem1 = {
&MenuItem2, /* next MenuItem structure */
0,0, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText3, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'H', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct Menu __aligned Menu4 = {
NULL, /* next Menu structure */
162,0, /* XY origin of Menu hit box relative to screen TopLeft */
63,0, /* Menu hit box width and height */
MENUENABLED, /* Menu flags */
"Special", /* text of Menu name */
&MenuItem1 /* MenuItem linked list pointer */
};
struct IntuiText __far __aligned IText4cc = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Easy", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem8cc = {
NULL, /* next MenuItem structure */
0,80, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
EXCLUDE_PATT^(0x400), /* each bit mutually-excludes a same-level Item */
(APTR)&IText4cc, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'E', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText4dd = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Intrmdt", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem8dd = {
&MenuItem8cc, /* next MenuItem structure */
0,72, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
EXCLUDE_PATT^(0x200), /* each bit mutually-excludes a same-level Item */
(APTR)&IText4dd, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'I', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText4ee = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Advancd", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem8ee = {
&MenuItem8dd, /* next MenuItem structure */
0,64, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKED+CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+HIGHCOMP, /* Item flags */
EXCLUDE_PATT^(0x100), /* each bit mutually-excludes a same-level Item */
(APTR)&IText4ee, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'A', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText4aa = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Supvsr", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem8aa = {
&MenuItem8ee, /* next MenuItem structure */
0,56, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText4aa, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'Y', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText4ab = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Book", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem8ab = {
&MenuItem8aa, /* next MenuItem structure */
0,48, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+CHECKED+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText4ab, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'B', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText4a = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"ShwThnk", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem8a = {
&MenuItem8ab, /* next MenuItem structure */
0,40, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText4a, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'V', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText4 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Thinking", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem8 = {
&MenuItem8a, /* next MenuItem structure */
0,32, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ/*+ITEMENABLED*/+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText4, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'T', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText5 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Undo", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem7 = {
&MenuItem8, /* next MenuItem structure */
0,24, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText5, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'U', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText6 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Move Now", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem6 = {
&MenuItem7, /* next MenuItem structure */
0,16, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText6, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'M', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText7 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"AutoPlay", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem5 = {
&MenuItem6, /* next MenuItem structure */
0,8, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText7, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText8 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Swap Sides", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem4 = {
&MenuItem5, /* next MenuItem structure */
0,0, /* XY of Item hitbox relative to TopLeft of parent hitbox */
123,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText8, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'S', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct Menu __aligned Menu3 = {
&Menu4, /* next Menu structure */
92,0, /* XY origin of Menu hit box relative to screen TopLeft */
63,0, /* Menu hit box width and height */
MENUENABLED, /* Menu flags */
"Control", /* text of Menu name */
&MenuItem4 /* MenuItem linked list pointer */
};
struct IntuiText __far __aligned IText9 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"ReverseBoard", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem11 = {
NULL, /* next MenuItem structure */
0,16, /* XY of Item hitbox relative to TopLeft of parent hitbox */
96,8, /* hit box width and height */
ITEMTEXT+/*ITEMENABLED+*/HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText9, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText10 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Edit Board", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem10 = {
&MenuItem11, /* next MenuItem structure */
0,8, /* XY of Item hitbox relative to TopLeft of parent hitbox */
96,8, /* hit box width and height */
ITEMTEXT+HIGHCOMP+ITEMENABLED, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText10, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText11 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
19,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"2-D", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem9 = {
&MenuItem10, /* next MenuItem structure */
0,0, /* XY of Item hitbox relative to TopLeft of parent hitbox */
96,8, /* hit box width and height */
CHECKED+CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText11, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct Menu __aligned Menu2 = {
&Menu3, /* next Menu structure */
46,0, /* XY origin of Menu hit box relative to screen TopLeft */
39,0, /* Menu hit box width and height */
MENUENABLED, /* Menu flags */
"View", /* text of Menu name */
&MenuItem9 /* MenuItem linked list pointer */
};
struct IntuiText __far __aligned IText12 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Quit", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem15 = {
NULL, /* next MenuItem structure */
0,40, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText12, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
'Q', /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText13a = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"List Game", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem14a = {
&MenuItem15, /* next MenuItem structure */
0,32, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText13a,/* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText13 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Save Game", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem14 = {
&MenuItem14a, /* next MenuItem structure */
0,24, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText13, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText14 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Load Game", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem13 = {
&MenuItem14, /* next MenuItem structure */
0,16, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText14, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct MenuItem __aligned MenuItem28 = {
&MenuItem13, /* next MenuItem structure */
0,8, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText37, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct IntuiText __far __aligned IText15 = {
TBLOCKPEN,1,COMPLEMENT, /* front and back text pens, drawmode and fill byte */
0,0, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"About..", /* pointer to text */
NULL /* next IntuiText structure */
};
struct MenuItem __aligned MenuItem12 = {
&MenuItem28, /* next MenuItem structure */
0,0, /* XY of Item hitbox relative to TopLeft of parent hitbox */
72,8, /* hit box width and height */
ITEMTEXT+ITEMENABLED+HIGHCOMP, /* Item flags */
0, /* each bit mutually-excludes a same-level Item */
(APTR)&IText15, /* Item render (IntuiText or Image or NULL) */
NULL, /* Select render */
NULL, /* alternate command-key */
NULL, /* SubItem list */
MENUNULL /* filled in by Intuition for drag selections */
};
struct Menu __aligned Menu1 = {
&Menu2, /* next Menu structure */
0,0, /* XY origin of Menu hit box relative to screen TopLeft */
39,0, /* Menu hit box width and height */
MENUENABLED, /* Menu flags */
"File", /* text of Menu name */
&MenuItem12 /* MenuItem linked list pointer */
};
#define MenuList1 Menu1
struct NewWindow __aligned NewWindowStructure1 = {
0,0, /* window XY origin relative to TopLeft of screen */
WIDTH,THEIGHT, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
MOUSEBUTTONS|MENUPICK|RAWKEY, /* IDCMP flags */
BACKDROP+BORDERLESS+ACTIVATE+NOCAREREFRESH, /* other window flags */
NULL, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
" ", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
WIDTH,THEIGHT, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
SHORT __far __aligned BorderVectors1[] = {
0,0,
81,0,
81,38,
0,38,
0,0
};
struct Border __far __aligned Border1 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
BorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned IText16 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
31,15, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"OK", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned Gadget1 = {
NULL, /* next gadget */
155,233, /* origin XY of hit box relative to window TopLeft */
80,37, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&Border1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&IText16, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
#define GadgetList2 Gadget1
struct IntuiText __far __aligned IText22 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
143,130, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"of Computers.", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText __far __aligned IText21 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
115,117, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"For the Amiga Family", /* pointer to text */
&IText22 /* next IntuiText structure */
};
struct IntuiText __far __aligned IText20 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
104,102, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Chess Program Available", /* pointer to text */
&IText21 /* next IntuiText structure */
};
struct IntuiText __far __aligned IText19 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
108,87, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"The strongest Playing", /* pointer to text */
&IText20 /* next IntuiText structure */
};
struct IntuiText __far __aligned IText18 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
126,31, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"by Roger Uzun", /* pointer to text */
&IText19 /* next IntuiText structure */
};
struct IntuiText __far __aligned IText17 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
131,18, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
VERSTRING, /* pointer to text */
&IText18 /* next IntuiText structure */
};
struct NewWindow __far __aligned NewWindowStructure2 = {
125,30, /* window XY origin relative to TopLeft of screen */
390,290, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
VANILLAKEY|GADGETUP, /* IDCMP flags */
SIMPLE_REFRESH+NOCAREREFRESH+ACTIVATE, /* other window flags */
&Gadget1, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
#ifdef _M68040
"UChess Pro", /* window title */
#else
"UChess Jr.", /* window title */
#endif
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
SHORT __far __aligned aBorderVectors1[] = {
0,0,
77,0,
77,25,
0,25,
0,0
};
struct Border __far __aligned aBorder1 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
aBorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned aIText1 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
16,8, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"KNIGHT", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned aGadget4 = {
NULL, /* next gadget */
55,124, /* origin XY of hit box relative to window TopLeft */
76,24, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&aBorder1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&aIText1, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT __far __aligned aBorderVectors2[] = {
0,0,
77,0,
77,25,
0,25,
0,0
};
struct Border __far __aligned aBorder2 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
aBorderVectors2, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned aIText2 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
15,8, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"BISHOP", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned aGadget3 = {
&aGadget4, /* next gadget */
55,92, /* origin XY of hit box relative to window TopLeft */
76,24, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&aBorder2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&aIText2, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT __far __aligned aBorderVectors3[] = {
0,0,
77,0,
77,25,
0,25,
0,0
};
struct Border __far __aligned aBorder3 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
aBorderVectors3, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned aIText3 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
19,8, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"ROOK", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned aGadget2 = {
&aGadget3, /* next gadget */
55,60, /* origin XY of hit box relative to window TopLeft */
76,24, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&aBorder3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&aIText3, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT __far __aligned aBorderVectors4[] = {
0,0,
77,0,
77,25,
0,25,
0,0
};
struct Border __far __aligned aBorder4 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
aBorderVectors4, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned aIText4 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
16,8, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"QUEEN", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned aGadget1 = {
&aGadget2, /* next gadget */
55,28, /* origin XY of hit box relative to window TopLeft */
76,24, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&aBorder4, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&aIText4, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct IntuiText __far __aligned aIText5 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
33,14, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Promote Pawn to", /* pointer to text */
NULL /* next IntuiText structure */
};
struct NewWindow __aligned NewWindowStructure6 = {
220,35, /* window XY origin relative to TopLeft of screen */
200,170, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
GADGETUP, /* IDCMP flags */
SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH, /* other window flags */
&aGadget1, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Promote Piece", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
#define MOVENOWMENUNUM 0x42
#define THINKMENUNUM 0x82
#define SHOWMENUNUM 0xa2
#define BOOKMENUNUM 0xc2
#define SUPERMENUNUM 0xe2
#define ADVANCEDMENUNUM 0x102
#define INTERMEDIATEMENUNUM 0x122
#define EASYMENUNUM 0x142
SHORT __far __aligned pBorderVectors1[] = {
0,0,
68,0,
68,31,
0,31,
0,0
};
struct Border __far __aligned pBorder1 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
pBorderVectors1, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned pIText1 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
13,11, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"DONE", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned pGadget4 = {
NULL, /* next gadget */
104,172, /* origin XY of hit box relative to window TopLeft */
67,30, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&pBorder1, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&pIText1, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT __far __aligned pBorderVectors2[] = {
0,0,
68,0,
68,31,
0,31,
0,0
};
struct Border __far __aligned pBorder2 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
pBorderVectors2, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned pIText2 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
117,132, /* was 13,11 XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"WHITE", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText __far __aligned pIText2a = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
117,132, /* was 13,11 XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"BLACK", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned pGadget3 = {
&pGadget4, /* next gadget */
104,121, /* origin XY of hit box relative to window TopLeft */
67,30, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&pBorder2, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
SHORT __far __aligned pBorderVectors3[] = {
0,0,
68,0,
68,31,
0,31,
0,0
};
struct Border __far __aligned pBorder3 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
pBorderVectors3, /* pointer to XY vectors */
NULL /* next border in list */
};
struct IntuiText __far __aligned pIText3 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
0,12, /* XY origin relative to container TopLeft */
&TOPAZ80, /* font pointer or NULL for default */
"Clear BD", /* pointer to text */
NULL /* next IntuiText structure */
};
struct Gadget __far __aligned pGadget2 = {
&pGadget3, /* next gadget */
105,82, /* origin XY of hit box relative to window TopLeft */
67,30, /* hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
BOOLGADGET, /* gadget type flags */
(APTR)&pBorder3, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
&pIText3, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
NULL, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
UBYTE __aligned pppSIBuff[4];
struct StringInfo __aligned pppSInfo = {
pppSIBuff, /* buffer where text will be edited */
NULL, /* optional undo buffer */
0, /* character position in buffer */
4, /* maximum number of characters to allow */
0, /* first displayed character buffer position */
0,0,0,0,0, /* Intuition initialized and maintained variables */
0, /* Rastport of gadget */
0, /* initial value for integer gadgets */
NULL /* alternate keymap (fill in if you set the flag) */
};
SHORT __far __aligned pBorderVectors4[] = {
0,0,
55,0,
55,16, /* was 55,24 and 0, 24 */
0,16,
0,0
};
struct Border __far __aligned pBorder4 = {
-1,-1, /* XY origin relative to container TopLeft */
TBLOCKPEN,0,JAM1, /* front pen, back pen and drawmode */
5, /* number of XY vectors */
pBorderVectors4, /* pointer to XY vectors */
NULL /* next border in list */
};
struct Gadget __far __aligned pGadget1 = {
&pGadget2, /* next gadget */
180,57, /* origin XY of hit box relative to window TopLeft */
54,15, /* was 54, 23 hit box width and height */
NULL, /* gadget flags */
RELVERIFY, /* activation flags */
STRGADGET, /* gadget type flags */
(APTR)&pBorder4, /* gadget border or image to be rendered */
NULL, /* alternate imagery for selection */
NULL, /* first IntuiText structure */
NULL, /* gadget mutual-exclude long word */
(APTR)&pppSInfo, /* SpecialInfo structure */
NULL, /* user-definable data */
NULL /* pointer to user-definable data */
};
struct IntuiText __far __aligned pIText8a = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
32,44, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"use space to clr a square", /* pointer to text */
NULL /* next IntuiText structure */
};
struct IntuiText __far __aligned pIText7 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
26,34, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Bd is updated after edit session", /* pointer to text */
&pIText8a /* next IntuiText structure */
};
struct IntuiText __far __aligned pIText6 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
68,62, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Piece to add", /* pointer to text */
&pIText7 /* next IntuiText structure */
};
struct IntuiText __far __aligned pIText5 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
59,24, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"pa1 for pawn at a1, etc.", /* pointer to text */
&pIText6 /* next IntuiText structure */
};
struct IntuiText __far __aligned pIText4 = {
TBLOCKPEN,0,JAM2, /* front and back text pens, drawmode and fill byte */
63,14, /* XY origin relative to container TopLeft */
NULL, /* font pointer or NULL for default */
"Enter Pieces in format", /* pointer to text */
&pIText5 /* next IntuiText structure */
};
struct NewWindow __far __aligned pNewWindowStructure1 = {
170,30, /* window XY origin relative to TopLeft of screen */
300,220, /* window width and height */
0,TBLOCKPEN, /* detail and block pens */
GADGETUP+CLOSEWINDOW, /* IDCMP flags */
WINDOWCLOSE+SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH, /* other window flags */
&pGadget1, /* first gadget in gadget list */
NULL, /* custom CHECKMARK imagery */
"Edit Board", /* window title */
NULL, /* custom screen pointer */
NULL, /* custom bitmap */
5,5, /* minimum width and height */
0xffff,0xffff, /* maximum width and height */
CUSTOMSCREEN /* destination screen type */
};
void DoEasy()
{
PlayMode = 0;
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
RethinkDisplay();
NewGame();
}
void DoAdvanced()
{
PlayMode = 2;
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
RethinkDisplay();
NewGame();
}
void DoIntermediate()
{
PlayMode = 1;
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
RethinkDisplay();
NewGame();
}
void
gsrand (unsigned int seed)
{
next = seed;
}
void calc_pgm_rating()
{
/* 34 secs on an RS/6000 which is about 2338, so to rate itself
rating = 2338 - 75*(log2(time) - log2(34)) */
int st;
unsigned int secs;
int rating;
int tmpbk,Old,oldtc;
int OldPM;
char tstr[32],tstr2[32];
OldPM = PlayMode;
PlayMode = 2;
tmpbk = Book;
oldtc = TCflag;
Old = MaxSearchDepth;
NewGame ();
UpdateDisplay (0, 0, 1, 0);
MaxSearchDepth = 6;
Book = 0;
TCflag = 0;
computer = computer ^ 1;
opponent = opponent ^ 1;
xwndw = (computer == white) ? WXWNDW : BXWNDW;
flag.force = false;
Sdepth = 0;
ShowMessage("Calculating.");
ShowMessage("Please wait.");
SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
st = time(0L);
SelectMove (computer, 1);
secs = st = time(0L) - st;
ClearPointer(wG);
if (st<4)
st = 4;
st = (st - 2)/6;
if (st > 200)
{
strcpy(tstr,"too slow Cannot rate");
}
else
{
if (st < 4)
st = 4;
#ifdef PL_60
rating = 2350 - (((75*log_e[st]) - (75*LOGE_34))/LN2);
#else /* patch level 61 */
rating = 2350 - (((75*log_e[st]) - (75*LOGE_16))/LN2);
#endif
#ifndef _M68040 /* small mem model */
rating -= 21;
#endif
sprintf(tstr,"USCF %04d",rating);
}
Book = tmpbk;
MaxSearchDepth = Old;
TCflag = oldtc;
PlayMode = OldPM;
NewGame ();
UpdateDisplay (0, 0, 1, 0);
sprintf(tstr2," %d secs",secs);
ShowMessage(tstr2);
ShowMessage(tstr);
}
int DoResign()
{
struct EasyStruct __aligned resignES = {
sizeof (struct EasyStruct),
0,
"Resignation Alert",
"Accept UChess's Resignation",
"Yes|No",
};
ULONG __aligned iflags=0L;
UBYTE __aligned volname[4]={0,0,0,0};
Delay(30L);
DisplayBeep(0L);
ResignOffered = -1;
/* return 0 if no resign accepted, yes if accepted */
return(EasyRequest( wG, &resignES, &iflags, volname ));
}
void GetEditText(s,color)
char *s;
int *color;
{ /* gets the edit string from the user */
/* returns # for clr bd, c for change colors and pa1 to put a pawn at a1*/
/* YOU MUST RETURN THE STRING IN ALL LOWER CASE! */
int dun;
long code,class;
int i;
APTR object;
struct IntuiMessage *message;
dun = 0;
s[0] = 0;
pppSIBuff[0] = '\0';
ActivateGadget(&pGadget1,wGEdit,NULL);
do {
WaitPort(wGEdit->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
{
code = message->Code;
object = message->IAddress;
class = message->Class;
ReplyMsg((struct Message *)message);
if (class == CLOSEWINDOW)
{
strcpy(s,".");
dun = 1;
}
else if (class == GADGETUP)
{ /* text */
if (object == (APTR)&pGadget1)
{
if (pppSIBuff[0])
{
dun = 1;
strcpy(s,pppSIBuff);
for(i=0;i<4;i++)
s[i] = tolower(s[i]);
}
}
else if (object == (APTR)&pGadget2)
{
dun = 1;
strcpy(s,"#");
}
else if (object == (APTR)&pGadget3)
{ /* white/black */
if (*color == white)
*color = black;
else
*color = white;
SetDrMd(wGEdit->RPort,JAM1);
SetAPen(wGEdit->RPort,0L);
RectFill(wGEdit->RPort,107,124,167,145);
if (*color == white)
PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
else
PrintIText(wGEdit->RPort,&pIText2a,0L,0L); /* white label */
}
else if (object == (APTR)&pGadget4)
{ /* done */
strcpy(s,".");
dun = 1;
}
}
}
} while (!dun);
DisplayBeep(0L);
}
void CloseAmigaEditWindow()
{
struct IntuiMessage *message;
while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
{
ReplyMsg((struct Message *)message);
}
CloseWindow(wGEdit);
if (DEPTH >= 6)
{
SetRGB32(vP,1,tmppal[0],tmppal[1],tmppal[2]);
}
else
{
SetRGB4(vP,1,((tmppal[0]>>8)&0xf),((tmppal[0]>>4)&0xf),((tmppal[0])&0xf));
}
}
int OpenAmigaEditWindow() /* opens a window for edit board */
{
if (!(wGEdit = OpenWindow(&pNewWindowStructure1)))
{
DisplayBeep(0L);
return(0);
}
if (DEPTH >= 6)
{
tmppal[0] = BigColorPalette[4];
tmppal[1] = BigColorPalette[5];
tmppal[2] = BigColorPalette[6];
SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
}
else
{
tmppal[0] = myPalette[1];
SetRGB4(vP,1,0xa,0xa,0xa);
}
pppSIBuff[0] = 0;
pppSIBuff[3] = 0;
PrintIText(wGEdit->RPort,&pIText4,0L,0L);
PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
return(1);
}
void EnableMoveNow()
{
if (MenuStripSet)
{
MoveNowOK = 1;
OnMenu(wG,MOVENOWMENUNUM);
}
}
void DisableMoveNow()
{
if (MenuStripSet)
{
MoveNowOK = 0;
OffMenu(wG,MOVENOWMENUNUM);
}
}
int GetFileName(char *s)
{
int tmp;
struct FileRequester *myFileReq;
struct TagItem Tags[2] = {
{ASLFR_Window,0L},
{0,0}
};
Tags[0].ti_Data = (ULONG)wG;
myFileReq = AllocAslRequest(ASL_FileRequest,Tags);
if (myFileReq)
{
tmp = AslRequest(myFileReq,Tags);
if (!tmp)
{
FreeAslRequest(myFileReq);
return(0);
}
strcpy(s,myFileReq->fr_Drawer);
if (s[0])
{
if ((s[strlen(s)-1] != ':')&&(s[strlen(s)-1] != '/'))
{
strcat(s,"/");
}
}
strcat(s,myFileReq->fr_File);
FreeAslRequest(myFileReq);
return(0xff);
}
else
return(0);
}
void
UpdateClocks (void)
{
char tempstr[16];
long ycoord;
INTSIZE m, s;
m = (INTSIZE) (et / 6000);
s = (INTSIZE) (et - 6000 * (long) m) / 100;
if (TCflag)
{
m = (INTSIZE) ((TimeControl.clock[player] - et) / 6000);
s = (INTSIZE) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
}
if (m < 0)
m = 0;
if (s < 0)
s = 0;
if (player == computer)
{
ycoord = TIMEYCOORD1;
}
else
{
ycoord = TIMEYCOORD2;
}
sprintf(tempstr,"%d:%02d ",m,s);
Move(rpG,540,ycoord);
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,540,ycoord-6,621,ycoord+5);
mySetABPenDrMd(rpG,1,bpen,JAM1);
Move(rpG,540,ycoord);
Text(rpG,tempstr,strlen(tempstr));
//sprintf(tempstr,"mvslft %d",TimeControl.moves[player]);
//ShowMessage(tempstr);
if (player == computer)
{
if ((!m)&&(s <= 1)&&(TCflag)&&(Sdepth > MINDEPTH))
{
flag.back = 1;
}
if ((TCflag)&&(Sdepth > MINDEPTH)&&(!m)&&
(TimeControl.moves[player] < 6)&&(s<((TimeControl.moves[player]-1)*5)))
{
flag.back = true;
}
/*printf("prev score = %d global_tmp_score = %d\n",previous_score,global_tmp_score);*/
if ((TCflag) && (!trying_again) && (ResponseTime < 9999998) && (Sdepth > MINDEPTH)
&& ((et) >= ((OrigResponse<<1) + ExtraTime + 101)))
{
if (global_tmp_score >= (previous_score - 75))
{
#ifdef TIMECNTRL1 /* this results in pgm taking lots of time! */
flag.musttimeout = true;
#else /* results in quciker timeout */
flag.back = true;
#endif
}
}
}
}
char DisplayPromoteRequestor(void);
char DisplayPromoteRequestor()
{
ULONG tmp[4];
int dun;
struct IntuiMessage __aligned *message;
struct Window __aligned *wG3;
UWORD __aligned code;
ULONG __aligned class;
APTR object;
char retchar='q';
if (DEPTH >= 6)
{
tmp[0] = BigColorPalette[4];
tmp[1] = BigColorPalette[5];
tmp[2] = BigColorPalette[6];
SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
}
else
{
tmp[0] = myPalette[1];
SetRGB4(vP,1,0xa,0xa,0xa);
}
if (!(wG3 = OpenWindow(&NewWindowStructure6)))
{
DisplayBeep(0L);
return('q');
}
PrintIText(wG3->RPort,&aIText5,0L,0L);
dun = 0;
do {
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
{
code = message->Code;
object = message->IAddress;
class = message->Class;
ReplyMsg((struct Message *)message);
dun = 1;
if (object == (APTR)&aGadget1)
{
retchar = 'q';
}
else if (object == (APTR)&aGadget2)
{
retchar = 'r';
}
else if (object == (APTR)&aGadget3)
{
retchar = 'b';
}
else if (object == (APTR)&aGadget4)
{
retchar = 'n';
}
}
} while (!dun);
CloseWindow(wG3);
if (DEPTH >= 6)
{
SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
}
else
{
SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
}
return(retchar);
}
void tFreeBitMap(struct BitMap *);
struct BitMap *tAllocBitMap(int,int,int,int,struct BitMap *);
struct BitMap *tAllocBitMap(wid,ht,depth,flags,friend)
int wid,ht,depth,flags;
struct BitMap *friend;
{
int i;
unsigned long tt;
LONG image_data;
WORD planes;
struct BitMap *tmp;
if (gfxversion < 39)
{
planes = RASSIZE(wid,ht);
if (!(tmp = AllocMem(sizeof (struct BitMap),MEMF_CLEAR)))
{
return(0);
}
InitBitMap(tmp,depth,wid,ht);
tt = planes*depth;
if (!(tmp->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
{
FreeMem(tmp,sizeof(struct BitMap));
return(0);
}
image_data = (LONG)tmp->Planes[0];
for(i=1;i<depth;i++)
{
tmp->Planes[i] = (PLANEPTR) (image_data + i * planes);
}
}
else
{
tmp = AllocBitMap(wid,ht,depth,flags,friend);
}
return(tmp);
}
void tFreeBitMap(bmap)
struct BitMap *bmap;
{
ULONG numbytes;
if (gfxversion < 39)
{
numbytes = bmap->Rows*bmap->BytesPerRow*bmap->Depth;
FreeMem(bmap->Planes[0],numbytes);
FreeMem(bmap,sizeof(struct BitMap));
}
else
{
FreeBitMap(bmap);
}
}
void HandleEvent(object)
APTR object;
{
if (object == (APTR)&MenuItem12) { DoAbout(); return; }
if (object == (APTR)&MenuItem13) { LoadAGame(); return; }
if (object == (APTR)&MenuItem14) { SaveAGame(); return; }
if (object == (APTR)&MenuItem14a) { ListAGame(); return; }
if (object == (APTR)&MenuItem15) { DoQuit(); return; }
if (object == (APTR)&MenuItem9) { Go2D(); return; }
if (object == (APTR)&MenuItem10) { EditBoard(); return; }
if (object == (APTR)&MenuItem11) { DoReverse(); return; }
if (object == (APTR)&MenuItem4) { DoSwap(); return; }
if (object == (APTR)&MenuItem5) { DoAutoPlay(); return; }
if (object == (APTR)&MenuItem6) { MoveNow(); return; }
if (object == (APTR)&MenuItem7) { TakeBack(); return; }
if (object == (APTR)&MenuItem8) { DoThinking(); return; }
if (object == (APTR)&MenuItem8a) { DoShwThnk(); return; }
if (object == (APTR)&MenuItem8aa) { DoSuper(); return; }
if (object == (APTR)&MenuItem8ab) { DoBookToggle(); return; }
if (object == (APTR)&MenuItem8ee) { DoAdvanced(); return; }
if (object == (APTR)&MenuItem8dd) { DoIntermediate(); return; }
if (object == (APTR)&MenuItem8cc) { DoEasy(); return; }
if (object == (APTR)&MenuItem1) { DoHint(); return; }
if (object == (APTR)&MenuItem2) { DoTest(); return; }
if (object == (APTR)&MenuItem3) { SetTime(); return; }
if (object == (APTR)&MenuItem3x) { calc_pgm_rating(); return; }
if (object == (APTR)&MenuItem3r) { ChangeSearchDepth(); return; }
if (object == (APTR)&MenuItem28)
{
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
RethinkDisplay();
NewGame();
return;
}
}
/* end of PowerWindows source generation */
void DoAbout()
{
int done=0;
struct IntuiMessage __aligned *message;
struct Window __aligned *wG3;
ULONG class,code;
if (!(wG3 = OpenWindow(&NewWindowStructure2)))
{
DisplayBeep(0L);
return;
}
PrintIText(wG3->RPort,&IText17,0L,0L);
do {
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
{
class = message->Class;
code = message->Code;
ReplyMsg((struct Message *)message);
if (class == GADGETUP)
done = 1;
else if (class == VANILLAKEY)
{
if ((code == 13)||(code == 10))
done = 1;
}
}
} while (!done);
CloseWindow(wG3);
}
void LoadAGame(void)
{
GetGame();
}
void SaveAGame(void)
{
SaveGame();
}
void ListAGame(void)
{
ListGame(0xff);
}
void DoQuit(void)
{
flag.quit = true;
}
void Go2D(void)
{
}
void DoReverse(void)
{
}
void DoSwap(void)
{
doswap = 1;
}
void DoAutoPlay(void)
{
hint = 0;
SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
doauto = 1;
}
void MoveNow(void)
{
}
void TakeBack(void)
{
char mvnstr[16];
int currpiece;
long tmp1,tmp2;
int r,c,l;
doundo = 1;
hint = 0;
if (GameCnt <= 0)
return;
for (r = 7; r >= 0; r--)
{
for (c = 0; c <= 7; c++)
{
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if (color[l] == neutral)
oldboard[r][c] = ' ';
else if (color[l] == white)
oldboard[r][c] = qxx[board[l]];
else
oldboard[r][c] = pxx[board[l]];
}
}
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
Undo();
for (r = 7; r >= 0; r--)
{
for (c = 0; c <= 7; c++)
{
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((color[l] == neutral)&&(oldboard[r][c] != ' '))
{
tmp1 = r & 1L;
tmp2 = c & 1L;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
}
else
{
if (color[l] == white)
currpiece = qxx[board[l]];
else
currpiece = pxx[board[l]];
if (currpiece != oldboard[r][c])
{
tmp1 = r & 1L;
tmp2 = c & 1L;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
LoadBobImage(currpiece);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
}
}
}
}
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,520,USERBOX,621,USERBOX+30);
Move(rpG,520,USERBOX+6);
if (computer != black)
sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
else
sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
mySetABPenDrMd(rpG,1,bpen,JAM1);
Text(rpG,mvnstr,strlen(mvnstr));
}
void DoThinking(void)
{
flag.easy = !flag.easy;
}
void DoShwThnk(void)
{
flag.post = !flag.post;
}
void DoSuper(void)
{
SupervisorMode = !SupervisorMode;
}
void DoBookToggle(void)
{
Book = Book ? 0 : BOOKFAIL;
}
void DoHint(void)
{
GiveHint();
}
void DoTest(void)
{
teston = 1;
}
int SetAmigaDepth()
{
int dun;
struct IntuiMessage __aligned *message;
struct Window __aligned *wG3;
UWORD __aligned code;
ULONG __aligned class;
APTR object;
ULONG tmp[3];
if (DEPTH >= 6)
{
tmp[0] = BigColorPalette[4];
tmp[1] = BigColorPalette[5];
tmp[2] = BigColorPalette[6];
SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
}
else
{
tmp[0] = myPalette[1];
SetRGB4(vP,1,0xa,0xa,0xa);
}
sprintf(Gadget6SIBuff,"%d",MaxSearchDepth);
NewWindowStructure5.FirstGadget = &Gadget6b;
if (!(wG3 = OpenWindow(&NewWindowStructure5)))
{
DisplayBeep(0L);
return(0);
}
Move(wG3->RPort,66,39);
Text(wG3->RPort,"Depth",5);
ActivateGadget(&Gadget6,wG3,NULL);
dun = 0;
do {
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
{
code = message->Code;
object = message->IAddress;
class = message->Class;
ReplyMsg((struct Message *)message);
#ifdef SELECTIVEBB
if (object != (APTR)&Gadget6b)
{
dun = 1;
}
#else
dun = 1;
#endif
}
} while (!dun);
CloseWindow(wG3);
if (DEPTH >= 6)
{
SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
}
else
{
SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
}
dun = atoi(Gadget6SIBuff);
if (dun > (MAXDEPTH-1))
dun = MAXDEPTH -1;
if (dun < MINDEPTH)
dun = MINDEPTH;
NewWindowStructure5.FirstGadget = &Gadget6;
return(dun);
}
void SetTime(void)
{
int dun;
char str[128];
struct IntuiMessage __aligned *message;
struct Window __aligned *wG3;
UWORD __aligned code;
ULONG __aligned class;
APTR object;
ULONG tmp[3];
struct Gadget *tg;
if (DEPTH >= 6)
{
tmp[0] = BigColorPalette[4];
tmp[1] = BigColorPalette[5];
tmp[2] = BigColorPalette[6];
SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
}
else
{
tmp[0] = myPalette[1];
SetRGB4(vP,1,0xa,0xa,0xa);
}
sprintf(Gadget6SIBuff,"%d",TCmoves);
sprintf(Gadget8SIBuff,"%d",(TCminutes));
if (!(wG3 = OpenWindow(&NewWindowStructure5)))
{
DisplayBeep(0L);
return;
}
PrintIText(wG3->RPort,&IText46,0L,0L);
ActivateGadget(&Gadget6,wG3,NULL);
dun = 0;
do {
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
{
code = message->Code;
object = message->IAddress;
class = message->Class;
ReplyMsg((struct Message *)message);
if (object != (APTR)&Gadget9)
{
if (object == (APTR)&Gadget6)
{
tg = &Gadget8;
ActivateGadget(tg,wG3,NULL);
}
else if (object == (APTR)&Gadget8)
dun = 1;
}
else
{
dun = 1;
}
}
} while (!dun);
CloseWindow(wG3);
if (DEPTH >= 6)
{
SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
}
else
{
SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
}
strcpy(str,Gadget6SIBuff);
strcat (str," ");
strcat(str,Gadget8SIBuff);
SelectLevel(str);
et = 0;
dun = player;
player = white;
UpdateClocks();
player = black;
UpdateClocks();
player = dun;
}
void DisplayError(str)
char *str;
{
struct IntuiMessage __aligned *message;
struct Window __aligned *wG3;
if (!(wG3 = OpenWindow(&NewWindowStructure2)))
{
DisplayBeep(0L);
return;
}
Move(wG3->RPort,2,25);
Text(wG3->RPort,str,strlen(str));
WaitPort(wG3->UserPort);
while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
ReplyMsg((struct Message *)message);
CloseWindow(wG3);
}
struct Library *LhBase;
struct LhBuffer *myLHBuffer;
int LoadBobData(void);
void FreeBobData(void);
int InitmyGels(void);
void CloseGels(void);
void LoadBobImage(piece)
long piece; /* loads bob with pieces image */
{
int i;
UWORD *temp;
LONG image_data;
WORD planes = RASSIZE (BOBWIDTH, BOBHEIGHT);
if (piece == BLANKDATA)
{
temp = BlankImageData;
}
else if (piece >= 'a') /* white pieces */
{
if (piece == 'p')
temp = WhiteImageData[0];
else if (piece == 'n')
temp = WhiteImageData[1];
else if (piece == 'b')
temp = WhiteImageData[2];
else if (piece == 'r')
temp = WhiteImageData[3];
else if (piece == 'q')
temp = WhiteImageData[4];
else if (piece == 'k')
temp = WhiteImageData[5];
}
else /* black pieces */
{
if (piece == 'P')
temp = BlackImageData[0];
else if (piece == 'N')
temp = BlackImageData[1];
else if (piece == 'B')
temp = BlackImageData[2];
else if (piece == 'R')
temp = BlackImageData[3];
else if (piece == 'Q')
temp = BlackImageData[4];
else if (piece == 'K')
temp = BlackImageData[5];
}
BobImage.ImageData = BobVSprite->ImageData = temp;
image_data = (LONG) BobImage.ImageData;
/* Map the image data to planes */
for (i = 0L; i < BOBDEPTH; ++i)
BobTransImage->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
TheBob->ImageShadow = BobVSprite->CollMask = temp;
temp += ((BOBHEIGHT+2)*BOBWIDINW);
BobVSprite->BorderLine = temp;
BobImage.ImageData = BobVSprite->ImageData;
BobTransImage->ti_sBM->Planes[0] = (char *)TheBob->ImageShadow;
for (i = 1; i < BOBDEPTH; i++)
BobTransImage->ti_sBM->Planes[i] = BobTransImage->ti_sBM->Planes[0];
lastpiece = piece;
}
int LoadBobData()
{
USHORT __aligned len;
long __aligned templong;
BPTR fh;
UBYTE *srcbuf;
int i;
if (!(srcbuf = AllocMem(BOBBLOCKSIZE,0L)))
{
return(0);
}
if (DEPTH < 6)
{
if (!(fh = Open("uchess:Pieces.lzw",MODE_OLDFILE)))
{
return(0);
}
}
else if (FasterDisplay)
{
if (!(fh = Open("uchess:Pieces64.lzw",MODE_OLDFILE)))
{
return(0);
}
}
else
{
if (!(fh = Open("uchess:Pieces256.lzw",MODE_OLDFILE)))
{
return(0);
}
}
if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
{
DisplayError("Cannot open lh.lib\n");
return(0);
}
if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
{
DisplayError("Cannot Create Buffer\n");
CloseLibrary(LhBase);
return(0);
}
for(i=0;i<6;i++)
{
if (Read(fh,(char *)&len,2L) != 2L)
{
Close(fh);
return(0);
}
templong = len;
if (Read(fh,srcbuf,templong) != templong)
{
Close(fh);
return(0);
}
if (!(WhiteImageData[i] =
(UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
LoadBobImage(piecechar[i]);
myLHBuffer->lh_Src = (APTR)srcbuf;
myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
myLHBuffer->lh_SrcSize = templong;
myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
LhDecode(myLHBuffer);
InitMasks(BobVSprite);
if (Read(fh,(char *)&len,2L) != 2L)
{
Close(fh);
return(0);
}
templong = len;
if (Read(fh,srcbuf,templong) != templong)
{
Close(fh);
return(0);
}
if (!(BlackImageData[i] =
(UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
LoadBobImage(piecechar[i+6]);
myLHBuffer->lh_Src = (APTR)srcbuf;
myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
myLHBuffer->lh_SrcSize = templong;
myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
LhDecode(myLHBuffer);
InitMasks(BobVSprite);
}
Close(fh);
FreeMem(srcbuf,BOBBLOCKSIZE);
DeleteBuffer(myLHBuffer);
CloseLibrary(LhBase);
LoadBobImage(BLANKDATA);
return(1);
}
void FreeBobData()
{
int i;
for(i=0;i<6;i++)
{
FreeMem((char *)WhiteImageData[i],BOBBLOCKSIZE);
FreeMem((char *)BlackImageData[i],BOBBLOCKSIZE);
}
FreeMem((char *)BlankImageData,BOBBLOCKSIZE);
}
int InitmyGels()
{
#ifdef EXTRAINIT
struct BitMap __aligned tmpBitMap;
#endif
int i;
UWORD *temp;
if (!(SpriteHead = (struct VSprite *)
AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(SpriteTail = (struct VSprite *)
AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(BobVSprite = (struct VSprite *)
AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(TheBob = (struct Bob *)
AllocMem(sizeof(struct Bob),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(myGelsInfo = (struct GelsInfo *)
AllocMem(sizeof(struct GelsInfo),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(myGelsInfo->nextLine = (WORD *)AllocMem(sizeof(WORD)*32,
MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(myGelsInfo->lastColor = (WORD **)AllocMem(sizeof(WORD)*32,
MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(myGelsInfo->collHandler = (struct collTable *)
AllocMem(sizeof(struct collTable),MEMF_PUBLIC|MEMF_CLEAR)))
{
return(0);
}
if (!(TheBob->SaveBuffer = (WORD *)
AllocMem(sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH,MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
if (!(temp = BobVSprite->ImageData =
(UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
BlankImageData = temp;
temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
TheBob->ImageShadow = BobVSprite->CollMask = temp;
temp += ((BOBHEIGHT+2)*BOBWIDINW);
BobVSprite->BorderLine = temp;
#ifdef DBL_BUFF
if (!(TheBob->DBuffer = (struct DBufPacket *)AllocMem
(sizeof(struct DBufPacket),MEMF_CHIP|MEMF_CLEAR)))
{
return(0);
}
if (!(TheBob->DBuffer->BufBuffer =
(WORD *)AllocRaster(BOBWIDTH,BOBHEIGHT*BOBDEPTH)))
{
return(0);
}
#endif
BOBPLANEPICK = 1;
for(i=0;i<DEPTH;i++)
{
BOBPLANEPICK *= 2;
}
BOBPLANEPICK--;
BobImage.LeftEdge = 0;
BobImage.TopEdge = 0;
BobImage.Width = BOBWIDTH;
BobImage.Height = BOBHEIGHT;
BobImage.Depth = BOBDEPTH;
BobImage.ImageData = BobVSprite->ImageData;
BobImage.PlanePick = BOBPLANEPICK;
BobImage.PlaneOnOff = BOBPLANEONOFF;
BobImage.NextImage = NULL;
if (!(BobTransImage = AllocTransImage(&BobImage)))
{
return(0);
}
myGelsInfo->leftmost = COLA;
myGelsInfo->rightmost = COLH+BOBWIDTH+1;
myGelsInfo->topmost = ROW8;
myGelsInfo->bottommost = ROW1+BOBHEIGHT+1;
rpG->GelsInfo = myGelsInfo;
InitGels((struct VSprite *)SpriteHead,SpriteTail,myGelsInfo);
WaitTOF();
BobVSprite->Flags = SAVEBACK | OVERLAY;
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
BobVSprite->Height = BOBHEIGHT;
BobVSprite->Width = BOBWIDINW;
BobVSprite->Depth = BOBDEPTH;
BobVSprite->MeMask = BOBMEMASK;
BobVSprite->HitMask = BOBHITMASK;
BobVSprite->VSBob = TheBob;
BobVSprite->PlanePick = BOBPLANEPICK;
BobVSprite->PlaneOnOff = BOBPLANEONOFF;
BobVSprite->VUserExt = 0;
TheBob->BobVSprite = BobVSprite;
if (!LoadBobData())
{
DisplayError("Cannot Load BOB data\n");
}
InitMasks(BobVSprite);
AddBob(TheBob,rpG);
#ifdef EXTRAINIT
InitBitMap(&tmpBitMap,DEPTH,BOBWIDTH,BOBHEIGHT);
tmpBitMap.Planes[0] = (char *)TheBob->SaveBuffer;
tt = BOBWIDINW*BOBHEIGHT*sizeof(WORD);
for(i=1;i<DEPTH;i++)
tmpBitMap.Planes[i] = tmpBitMap.Planes[0] + (tt*i);
BltBitMap(myBitMap,BobVSprite->X,BobVSprite->Y,&tmpBitMap,0L,0L,BOBWIDTH,BOBHEIGHT,0xc0L,0xffL,0L);
#endif
WaitTOF();
MakeScreen(sC);
RethinkDisplay();
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
MakeScreen(sC);
RethinkDisplay();
WaitTOF();
return(1);
}
void CloseGels()
{
RemIBob(TheBob,rpG,vP);
FreeBobData();
#ifdef DBL_BUFF
FreeRaster((PLANEPTR)TheBob->DBuffer->BufBuffer,BOBWIDTH,BOBHEIGHT*BOBDEPTH);
FreeMem((char *)TheBob->DBuffer,sizeof(struct DBufPacket));
#endif
FreeTransImage(BobTransImage);
FreeMem((char *)TheBob->SaveBuffer,
sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH);
FreeMem((char *)myGelsInfo->collHandler,sizeof(struct collTable));
FreeMem((char *)myGelsInfo->lastColor,sizeof(WORD)*32);
FreeMem((char *)myGelsInfo->nextLine,sizeof(WORD)*32);
FreeMem((char *)myGelsInfo,sizeof(struct GelsInfo));
FreeMem((char *)TheBob,sizeof(struct Bob));
FreeMem((char *)BobVSprite,sizeof(struct VSprite));
FreeMem((char *)SpriteTail,sizeof(struct VSprite));
FreeMem((char *)SpriteHead,sizeof(struct VSprite));
}
struct TransImage *
AllocTransImage (struct Image * im)
{
if (im)
{
LONG msize = sizeof (struct TransImage);
struct TransImage *ti;
if (ti = (struct TransImage *) AllocMem (msize, MEMF_CLEAR))
{
LONG image_data = (LONG) im->ImageData;
UWORD depth = im->Depth;
UWORD width = im->Width;
UWORD height = im->Height;
WORD planes = RASSIZE (width, height);
WORD i;
/* Remember the image */
ti->ti_IM = im;
/* Initialize the Image bitmap */
InitBitMap (&ti->ti_BM, depth, width, height);
/* Map the image data to planes */
for (i = 0L; i < depth; ++i)
ti->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
/* Initialize the Image rastport */
InitRastPort (&ti->ti_RP);
ti->ti_RP.BitMap = &ti->ti_BM;
if (ti->ti_sBM = AllocShadowBM (depth, width, height))
{
if (ti->ti_sRP = AllocShadowRP (ti->ti_sBM))
{
return (ti);
}
FreeShadowBM (ti->ti_sBM);
}
FreeMem ((APTR) ti, msize);
}
}
return (NULL);
}
VOID
FreeTransImage (struct TransImage * ti)
{
if (ti)
{
LONG msize = sizeof (struct TransImage);
/* Free the shadow RastPort */
FreeShadowRP (ti->ti_sRP);
/* Free the shadow BitMap */
FreeShadowBM (ti->ti_sBM);
/* Free the temporary buffer */
FreeMem ((APTR) ti, msize);
}
}
VOID
FreeShadowBM (struct BitMap *sbm)
{
if (sbm)
{
#ifdef ALLOCFORREAL
LONG msize;
msize = RASSIZE (8 * (sbm->BytesPerRow), sbm->Rows);
if (sbm->Planes[0])
{
FreeMem ((APTR)sbm->Planes[0], msize);
}
#else
FreeMem ((APTR)sbm, sizeof (struct BitMap));
#endif
}
}
VOID
FreeShadowRP (struct RastPort *srp)
{
if (srp)
{
FreeMem (srp, sizeof (struct RastPort));
}
}
struct BitMap *
AllocShadowBM (UWORD depth, UWORD width, UWORD height)
{
LONG msize = sizeof (struct BitMap);
struct BitMap *bm;
WORD i;
/* Allocate a bitmap */
if (bm = (struct BitMap *) AllocMem (msize, MEMF_CLEAR))
{
#ifdef ALLOCFORREAL
LONG rsize = RASSIZE (width, height);
#endif
/* Initialize the bitmap */
InitBitMap (bm, depth, width, height);
#ifdef ALLOCFORREAL
/* Allocate one plane */
if (bm->Planes[0] = (PLANEPTR) AllocMem (rsize, MEMF_CHIP | MEMF_CLEAR))
{
/* All planes point to the first plane */
for (i = 1; i < depth; i++)
bm->Planes[i] = bm->Planes[0];
return (bm);
}
FreeMem ((APTR) bm, msize);
#else
bm->Planes[0] = (char *)TheBob->ImageShadow;
for (i = 1; i < depth; i++)
bm->Planes[i] = bm->Planes[0];
return (bm);
#endif
}
return (NULL);
}
struct RastPort *
AllocShadowRP (struct BitMap *bm)
{
LONG msize = sizeof (struct RastPort);
struct RastPort *rp;
/* Allocate a RastPort */
if (rp = (struct RastPort *) AllocMem (msize, MEMF_CHIP))
{
/* Initialize the new RastPort */
InitRastPort (rp);
/* Point the RastPort's BitMap... */
rp->BitMap = bm;
}
return (rp);
}
VOID
ClipBlitTrans (
struct RastPort *rp, /* source RastPort */
WORD sx, WORD sy, /* source top-left edge */
struct RastPort *drp, /* destination RastPort */
WORD dx, WORD dy, /* destination top-left edge */
WORD width, WORD height, /* width & height of image to blit */
struct RastPort *Srp) /* shadow RastPort */
{
/* make the shadow */
ClipBlit (rp, sx, sy, Srp, 0, 0, width, height, 0xe0);
ClipBlit (Srp, 0, 0, drp, dx, dy, width, height, 0x20); /* blit cookie cutter outline */
ClipBlit (rp, sx, sy, drp, dx, dy, width, height, 0xe0); /* now fill in image */
}
int LoadFullBitMap(void);
int LoadFullBitMap()
{
char errstr[40];
char fname[80];
long count;
USHORT len;
char *srcbuf;
ULONG tt;
BPTR fh;
BPTR __aligned fp;
struct BitMap *tmpBitMap;
struct FileInfoBlock __aligned *myFileInfoBlock;
if (DEPTH < 6)
strcpy(fname,"uchess:Chess.lzw");
else if (FasterDisplay)
strcpy(fname,"uchess:Chess64.lzw");
else
strcpy(fname,"uchess:Chess256.lzw");
if (!(myFileInfoBlock =
(struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock),MEMF_PUBLIC)))
{
DisplayError("No Mem now for finfo block");
return(0);
}
if (!(fp = Lock(fname,ACCESS_READ)))
{
FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
return(0);
}
if (!(Examine(fp,myFileInfoBlock)))
{
DisplayError("Cannot get finfo");
UnLock(fp);
FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
return(0);
}
UnLock(fp);
count = myFileInfoBlock->fib_Size - 2L;
FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
/* before unpacking the bitmap, save the titlebar area in a tmp bitmap */
if (!(tmpBitMap = tAllocBitMap(WIDTH,MENUBARHT,DEPTH,BMF_CLEAR,myBitMap)))
{
return(0);
}
BltBitMap(myBitMap,0,0,tmpBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
if (!(srcbuf = AllocMem(count,0L)))
{
sprintf(errstr,"Cannot allocate lharc %d byte buffer",count);
DisplayError(errstr);
return(0);
}
if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
{
DisplayError("Cannot open lh.lib");
return(0);
}
if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
{
DisplayError("Cannot Create Buffer");
CloseLibrary(LhBase);
return(0);
}
#ifdef GG
if (DEPTH < 6)
{
#endif
if (!(fh = Open(fname,MODE_OLDFILE)))
{
DisplayError("Cannot open chess file");
return(0);
}
if (Read(fh,(char *)&len,2L) != 2L)
{
DisplayError("Cannot read chess file");
Close(fh);
return(0);
}
if (Read(fh,srcbuf,count) != count)
{
DisplayError("Cannot read chess file2");
Close(fh);
return(0);
}
Close(fh);
myLHBuffer->lh_Src = (APTR)srcbuf;
myLHBuffer->lh_Dst = (APTR)myBitMap->Planes[0];
myLHBuffer->lh_SrcSize = count;
tt = WIDTH/8L;
tt = tt*HEIGHT;
tt = tt*DEPTH;
myLHBuffer->lh_DstSize = tt;
LhDecode(myLHBuffer);
#ifdef GG
}
else
{ /* depth == 8 */
if (!(fh = Open(fname,MODE_OLDFILE)))
{
return(0);
}
for(i=0;i<8;i++)
{
if (Read(fh,(char *)&len,2L) != 2L)
{
Close(fh);
return(0);
}
templen = len;
if (Read(fh,srcbuf,templen) != templen)
{
Close(fh);
return(0);
}
myLHBuffer->lh_Src = (APTR)srcbuf;
myLHBuffer->lh_Dst = (APTR)myBitMap->Planes[i];
myLHBuffer->lh_SrcSize = templen;
tt = WIDTH/8L;
tt = tt*HEIGHT;
myLHBuffer->lh_DstSize = tt;
LhDecode(myLHBuffer);
}
Close(fh);
} /* DEPTH == 8 clause */
#endif
FreeMem(srcbuf,count);
DeleteBuffer(myLHBuffer);
CloseLibrary(LhBase);
BltBitMap(tmpBitMap,0,0,myBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
tFreeBitMap(tmpBitMap);
mySetABPenDrMd(rpG,1,bpen,JAM1);
Move(rpG,511,COMPUTERBOX-10);
#ifdef _M68040
strcpy(fname,"UChess Pro:");
#else
strcpy(fname,"UChess Jr.:");
#endif
Text(rpG,fname,strlen(fname));
Move(rpG,511,USERBOX-10);
strcpy(fname,"Puny Human:");
Text(rpG,fname,strlen(fname));
BltBitMap(myBitMap,COLB,ROW5,WhiteBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
BltBitMap(myBitMap,COLA,ROW5,BlackBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
RethinkDisplay();
return(1);
}
int mAllocBitMap(void);
int mAllocBitMap()
{
REG USHORT i;
unsigned long tt;
ULONG temp2;
char *temp;
if (DEPTH < 6)
{
if (!(myBitMap = (struct BitMap *)AllocMem(sizeof(struct BitMap),0L)))
{
return(0);
}
InitBitMap(myBitMap,DEPTH,WIDTH,HEIGHT);
tt = WIDTH/8L;
tt = tt*HEIGHT;
tt = tt*DEPTH;
if (!(myBitMap->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
{
FreeMem((char *)myBitMap,sizeof(struct BitMap));
return(0);
}
Orig_PlanePtr = (char *)myBitMap->Planes[0];
temp = (char *)myBitMap->Planes[0];
temp2 = WIDTH/8L;
temp2 *= HEIGHT;
for (i=1;i<DEPTH;i++)
{
temp += temp2;
myBitMap->Planes[i] = (PLANEPTR)temp;
}
}
else /* 8 bit screen */
{
if (!(myBitMap = AllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
0L)))
{
return(0);
}
}
NewScreenStructure.CustomBitMap = myBitMap;
if (!(WhiteBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
BMF_CLEAR,myBitMap)))
{
return(0);
}
if (!(BlackBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
BMF_CLEAR,myBitMap)))
{
return(0);
}
return(1);
}
void FreeTheBitMap(void);
void FreeTheBitMap()
{
tFreeBitMap(BlackBitMap);
tFreeBitMap(WhiteBitMap);
if (DEPTH < 6)
{
tt = WIDTH / 8L;
tt *= HEIGHT;
tt *= DEPTH;
FreeMem(Orig_PlanePtr,tt);
FreeMem((char *)myBitMap,sizeof(struct BitMap));
}
else
{
FreeBitMap(myBitMap);
}
}
void AmigaShutDown(void);
int AmigaStartup(void);
int AmigaStarted = 0;
int AmigaStartup()
{
flag.post = false;
if (!(myTextFont = OpenFont(&TOPAZ80)))
{
return(0);
}
if (gfxversion < 39)
DEPTH = 4;
else
{
if (v15Khz)
myTagList[0].ti_Data = HIRES|LACE|PAL_MONITOR_ID;
if (Super72)
myTagList[0].ti_Data = (SUPER72_MONITOR_ID | SUPERLACE_KEY);
NewScreenStructure2.Type |= NS_EXTENDED;
NewScreenStructure2.Extension = myTagList;
NewScreenStructure2.Height = 480;
NewScreenStructure2.Depth = 8;
NewScreenStructure2.BlockPen = 251;
if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
{
CloseScreen(sC);
DEPTH = 8;
}
else
{
myTagList[0].ti_Data = HIRES|LACE|PAL_MONITOR_ID;
if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
{
CloseScreen(sC);
DEPTH = 8;
}
else
{
myTagList[0].ti_Data = HIRES|LACE;
DEPTH = 4;
}
}
}
if (DEPTH == 8)
{
if (FasterDisplay)
{
DEPTH = 6;
MBLOCKPEN = 61;
BACKGNDTEXTCOLOR = 57;
}
else
{
MBLOCKPEN = 251;
BACKGNDTEXTCOLOR = 0xe0;
}
TIMEYCOORD1 = 120;
TIMEYCOORD2 = 230;
USERBOX=168;
SYSTEMBOX = USERBOX + 112;
SYSBOXLEN = 102;
COMPUTERBOX=60;
BOBDEPTH = DEPTH;
ROW8 = 24;
BOBHEIGHT = 55;
HEIGHT = 480;
NewScreenStructure.Type |= NS_EXTENDED;
NewScreenStructure.Extension = myTagList;
NewScreenStructure.Height = HEIGHT;
NewScreenStructure.Depth = DEPTH;
NewScreenStructure.BlockPen = MBLOCKPEN;
NewWindowStructure1.Height = HEIGHT;
NewWindowStructure1.MaxHeight = HEIGHT;
NewWindowStructure1.BlockPen = MBLOCKPEN;
NewWindowStructure2.BlockPen = MBLOCKPEN;
NewWindowStructure5.BlockPen = MBLOCKPEN;
NewWindowStructure6.BlockPen = MBLOCKPEN;
pNewWindowStructure1.BlockPen = MBLOCKPEN;
Border6.FrontPen = Border7.FrontPen =
Border9.FrontPen = Border1.FrontPen = MBLOCKPEN;
aBorder1.FrontPen = aBorder2.FrontPen =
aBorder3.FrontPen = aBorder4.FrontPen =
pBorder1.FrontPen = pBorder2.FrontPen =
pBorder3.FrontPen = pBorder4.FrontPen = MBLOCKPEN;
pIText1.FrontPen =
pIText2.FrontPen =
pIText2a.FrontPen =
pIText3.FrontPen =
pIText4.FrontPen =
pIText5.FrontPen =
pIText6.FrontPen =
pIText7.FrontPen =
pIText8a.FrontPen =
IText93.FrontPen =
IText47.FrontPen =
IText46.FrontPen =
IText37.FrontPen =
IText1.FrontPen =
IText1r.FrontPen =
IText2.FrontPen =
IText2x.FrontPen =
IText3.FrontPen =
IText4.FrontPen =
IText4aa.FrontPen =
IText4ab.FrontPen =
IText4cc.FrontPen =
IText4dd.FrontPen =
IText4ee.FrontPen =
IText4a.FrontPen =
IText5.FrontPen =
IText6.FrontPen =
IText7.FrontPen =
IText8.FrontPen =
IText9.FrontPen =
IText10.FrontPen =
IText11.FrontPen =
IText12.FrontPen =
IText13.FrontPen =
IText13a.FrontPen =
IText14.FrontPen =
IText15.FrontPen =
IText16.FrontPen =
IText22.FrontPen =
IText21.FrontPen =
IText20.FrontPen =
IText19.FrontPen =
IText18.FrontPen =
aIText1.FrontPen =
aIText2.FrontPen =
aIText3.FrontPen =
aIText4.FrontPen =
aIText5.FrontPen =
IText17.FrontPen = MBLOCKPEN;
}
if (!(mAllocBitMap()))
{
CloseFont(myTextFont);
return(0);
}
RowArray[0] = ROW1;
RowArray[1] = ROW2;
RowArray[2] = ROW3;
RowArray[3] = ROW4;
RowArray[4] = ROW5;
RowArray[5] = ROW6;
RowArray[6] = ROW7;
RowArray[7] = ROW8;
if (!(sC = OpenScreen((struct NewScreen *)&NewScreenStructure)))
{
FreeTheBitMap();
CloseFont(myTextFont);
return(0);
}
vP = &sC->ViewPort;
if (DEPTH >= 6)
{
if (!FasterDisplay)
LoadRGB32(&(sC->ViewPort),BigColorPalette);
else
LoadRGB32(&(sC->ViewPort),Big64Palette);
}
else
LoadRGB4(&(sC->ViewPort),myPalette,16);
NewWindowStructure1.Screen = sC;
pNewWindowStructure1.Screen = sC;
NewWindowStructure2.Screen = sC;
NewWindowStructure5.Screen = sC;
NewWindowStructure6.Screen = sC;
wG = OpenWindow(&NewWindowStructure1); /* open the window */
if ( wG == NULL )
{
CloseScreen(sC);
CloseFont(myTextFont);
FreeTheBitMap();
return(0);
}
globalsignalset = WINDOWSIGNAL;
rpG = wG->RPort; /* get a rastport pointer for the window */
SetFont(rpG,myTextFont);
Delay(25L); /* crashes from wb if I do not do this! */
if (!LoadFullBitMap())
{
return(0);
}
/* SetMenuStrip(wG,&MenuList1); /* attach any Menu */
SetDrMd(rpG,JAM1);
if (!InitmyGels())
{
CloseScreen(sC);
CloseFont(myTextFont);
FreeTheBitMap();
return(0);
}
else
{
AmigaStarted = 1;
if (gfxversion > 38)
bpen = GetBPen(rpG);
return(1);
}
}
void AmigaShutDown()
{
struct IntuiMessage __aligned *message;
ClearPointer(wG);
CloseGels();
while(message = (struct IntuiMessage *)GetMsg(wG->UserPort))
ReplyMsg((struct Message *)message);
CloseWindow(wG);
CloseScreen(sC);
FreeTheBitMap();
CloseFont(myTextFont);
/* system("delete >nil: CLP58.#?");*/
}
void ShowMessage(str)
char *str;
{
char tstr[16];
int done = 0;
int i=0;
struct BitMap *tempBitMap;
int j,k,lim;
int ycoord;
if (str[strlen(str)-1] == '\n')
{
str[strlen(str)-1] = 0;
}
if (!(tempBitMap = tAllocBitMap(160,160,DEPTH,BMF_CLEAR,myBitMap)))
{
DisplayBeep(0L);
Delay(10L);
DisplayBeep(0L);
Delay(15L);
DisplayBeep(0L);
Delay(25L);
DisplayBeep(0L);
return;
}
ycoord = SYSTEMBOX+6;
/* scroll down 3 lines (30 pixels) */
BltBitMap(myBitMap,510,SYSTEMBOX,tempBitMap,0L,0L,621-510+1,SYSBOXLEN,0xc0L,0xffL,0L);
BltBitMap(tempBitMap,0,0,myBitMap,510,SYSTEMBOX+30,621-510+1,SYSBOXLEN-30,0xc0L,0xffL,0L);
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,510,SYSTEMBOX-1,621,SYSTEMBOX+29);
mySetABPenDrMd(rpG,1,bpen,JAM1);
do {
j = i;
if (strlen(str) <= 14)
{
done = 1;
strcpy(tstr,str);
}
else
{
lim = j + 14;
if (lim >= strlen(str))
{
done = 1;
lim = strlen(str);
}
for(k=0;i<lim;i++,k++)
tstr[k] = str[i];
tstr[k] = 0;
}
Move(rpG,510,ycoord); /* was 509,ycord */
ycoord += 10;
Text(rpG,tstr,strlen(tstr));
} while (!done);
tFreeBitMap(tempBitMap);
}
void DisplayComputerMove(str)
char *str;
{
char tstr[16];
int done = 0;
int i=0;
int j,k,lim;
int ycoord;
if (str[strlen(str)-1] == '\n')
{
str[strlen(str)-1] = 0;
}
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,520,COMPUTERBOX,621,COMPUTERBOX+30);
ycoord = COMPUTERBOX+6;
do {
j = i;
if (strlen(str) <= 12)
{
done = 1;
strcpy(tstr,str);
}
else
{
lim = j + 12;
if (lim >= strlen(str))
{
done = 1;
lim = strlen(str);
}
for(k=0;i<lim;i++,k++)
tstr[k] = str[i];
tstr[k] = 0;
}
mySetABPenDrMd(rpG,1,bpen,JAM1);
Move(rpG,520,ycoord);
ycoord += 10;
Text(rpG,tstr,strlen(tstr));
} while (!done);
}
void DoLegalMove(str)
char *str;
{
long mpiece;
char piece;
int r,c,l;
int ecol,erow,scol,srow,side,tmp1,tmp2,incrx,incry,i;
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
r = str[3] - '1';
c = str[2] - 'a';
tmp1 = r & 1;
tmp2 = c & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
RethinkDisplay();
WaitTOF();
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((color[l] == neutral))
{
ExitChess();
return;
}
else if (color[l] == white)
piece = qxx[board[l]]; /* white are lower case pieces */
else
piece = pxx[board[l]]; /* black are upper case pieces */
if ((DestRow == 7)||(!DestRow))
{ /* possible promotion */
mpiece = piece;
LoadBobImage(mpiece);
}
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[DestCol],RowArray[DestRow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
AddBob(TheBob,rpG);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
if (piece >= 'a')
{
mpiece = 'r';
srow = 0;
erow = 0;
side = white;
if (str[2] == 'g') /* king side white */
{
scol = 7;
ecol = 5;
}
else
{
ecol = 3;
scol = 0;
}
}
else
{
mpiece = 'R';
srow = 7;
erow = 7;
side = black;
if (str[2] == 'g') /* king side black */
{
scol = 7;
ecol = 5;
}
else
{
ecol = 3;
scol = 0;
}
}
if (Castled[side])
{
Castled[side] = 0;
tmp1 = srow & 1;
tmp2 = scol & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
BobVSprite->X = ColArray[scol];
BobVSprite->Y = RowArray[srow];
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
LoadBobImage(mpiece);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
incry = (RowArray[erow] - RowArray[srow])/8;
incrx = (ColArray[ecol] - ColArray[scol])/8;
for(i=0;i<8;i++)
{
BobVSprite->X += incrx;
BobVSprite->Y += incry;
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
LoadBobImage(BLANKDATA);
AddBob(TheBob,rpG);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
else /* check EnPassant */
{
side ^= 1;
if (myEnPassant[side])
{
myEnPassant[side] = 0;
scol = str[2] - 'a';
if (str[3] == '3') /* white is removed from bd at 4*/
{
srow = 3;
}
else /* black is removed at pos 5 */
{
srow = 4;
}
tmp1 = srow & 1;
tmp2 = scol & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
}
}
}
void DrawAmigaBoard()
{
int r,c,l,tmp1,tmp2;
int piece;
LoadBobImage(BLANKDATA);
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
SortGList(rpG);
DrawGList(rpG,vP);
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
for(r=0;r<8;r++)
for(c=0;c<8;c++)
{
tmp1 = r & 1;
tmp2 = c & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if (color[l] == white)
piece = qxx[board[l]]; /* white are lower case pieces */
else
piece = pxx[board[l]]; /* black are upper case pieces */
if (color[l] != neutral)
{
BobVSprite->X = ColArray[c];
BobVSprite->Y = RowArray[r];
LoadBobImage(piece);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
}
}
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
AddBob(TheBob,rpG);
}
void GetOperatorEntry(str)
char *str;
{
char __aligned PromoteChar;
char mvnstr[16];
ULONG signals;
char __aligned tempstr[40];
struct IntuiMessage __aligned *message;
long done=0;
long done2;
int ilen=0;
int r,c,l,piece;
long __aligned class,code;
int MouseX,MouseY;
long tmp1,tmp2;
ClearPointer(wG);
if (CheckIllegal)
{
CheckIllegal = 0;
if (IllegalMove)
{ /* put guy back! */
IllegalMove = 0;
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
AddBob(TheBob,rpG);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
}
while (message = (struct IntuiMessage *)GetMsg(wG->UserPort))
{
ReplyMsg((struct Message *)message);
}
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,520,USERBOX,621,USERBOX+30);
Move(rpG,520,USERBOX+6);
if (computer != black)
sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
else
sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
mySetABPenDrMd(rpG,1,bpen,JAM1);
Text(rpG,mvnstr,strlen(mvnstr));
tempstr[0] = 0;
PromoteChar = 0;
OnMenu(wG,SHOWMENUNUM);
OnMenu(wG,SUPERMENUNUM);
OnMenu(wG,THINKMENUNUM);
OnMenu(wG,BOOKMENUNUM);
do {
if (!globalmessage_valid)
signals = Wait(globalsignalset);
if ((signals & WINDOWSIGNAL)||(globalmessage_valid))
{
message = (struct IntuiMessage *)1;
while (message)
{
if (!globalmessage_valid)
message = (struct IntuiMessage *)GetMsg(wG->UserPort);
if ((message)||(globalmessage_valid))
{
if (!globalmessage_valid)
{
class = message->Class;
code = message->Code;
MouseX = message->MouseX;
MouseY = message->MouseY;
ReplyMsg((struct Message *)message);
}
else
{
class = globalmessage.Class;
code = globalmessage.Code;
MouseX = globalmessage.MouseX;
MouseY = globalmessage.MouseY;
globalmessage_valid = 0L;
}
if ( class == MENUPICK ) /* MenuItems */
{
HandleEvent((APTR)ItemAddress(&MenuList1,code));
if (flag.quit)
done = 1;
else
{
if (teston)
{
done = 1;
teston = 0;
strcpy(tempstr,"test");
}
else if (doswap)
{
done = 1;
doswap = 0;
strcpy(tempstr,"switch");
}
else if (doauto)
{
done = 1;
doauto = 0;
strcpy(tempstr,"both");
}
else if (doundo)
{
done = 1;
doundo = 0;
strcpy(tempstr,"help");
}
}
}
else if (class == RAWKEY)
{
if (code < 80)
{
code = cookedchar[code];
if ((code == 13)||(code == 10))
{
done = 1;
}
else if ((code == 7)&&(ilen)) /* backspace */
{
tempstr[strlen(tempstr)-1] = '\0';
mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
RectFill(rpG,520,USERBOX,621,USERBOX+30);
mySetABPenDrMd(rpG,1,bpen,JAM1);
Move(rpG,520,USERBOX+6);
if (computer != black)
sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
else
sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
Text(rpG,mvnstr,strlen(mvnstr));
Text(rpG,tempstr,strlen(tempstr));
ilen--;
}
else if ((isalnum(code)||(code == '-')||(code == '/')) && (strlen(tempstr) < 12))
{
tempstr[ilen] = tolower(code);
mySetABPenDrMd(rpG,1,bpen,JAM1);
Move(rpG,520,USERBOX+6);
ilen++;
tempstr[ilen] = 0;
if (computer != black)
sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
else
sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
Text(rpG,mvnstr,strlen(mvnstr));
Text(rpG,tempstr,strlen(tempstr));
}
} /* code < 80 */
}
else if ((class == MOUSEBUTTONS)&&(!(flag.quit || flag.mate || flag.force)))
{
if ((code == SELECTDOWN) &&
((MouseY <= (ROW1+SQUAREHEIGHT)) && (MouseY >= ROW8) && (MouseX <= (COLH+BOBWIDTH)) &&
(MouseX >= COLA)))
{
if (MouseX < COLB)
OrigCol = 0;
else if (MouseX < COLC)
OrigCol = 1;
else if (MouseX < COLD)
OrigCol = 2;
else if (MouseX < COLE)
OrigCol = 3;
else if (MouseX < COLF)
OrigCol = 4;
else if (MouseX < COLG)
OrigCol = 5;
else if (MouseX < COLH)
OrigCol = 6;
else
OrigCol = 7;
if (MouseY < ROW7)
OrigRow = 7;
else if (MouseY < ROW6)
OrigRow = 6;
else if (MouseY < ROW5)
OrigRow = 5;
else if (MouseY < ROW4)
OrigRow = 4;
else if (MouseY < ROW3)
OrigRow = 3;
else if (MouseY < ROW2)
OrigRow = 2;
else if (MouseY < ROW1)
OrigRow = 1;
else
OrigRow = 0;
tmp1 = OrigRow & 1L;
tmp2 = OrigCol & 1L;
done2 = 0;
r = OrigRow;
c = OrigCol;
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((color[l] == neutral)||(opponent != color[l]))
{
done2 = 1;
}
else if (color[l] == white)
piece = qxx[board[l]]; /* white are lower case pieces */
else
piece = pxx[board[l]]; /* black are upper case pieces */
if (!done2)
{
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[OrigCol],
RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[OrigCol],
RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
CheckIllegal = 1;
IllegalMove = 0;
/* NOW POSITION BOB AND LOAD IN ITS CORRECT PIECE IMAGE */
LoadBobImage(piece);
BobVSprite->X = MouseX - 24;
BobVSprite->Y = MouseY - 16;
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags | INTUITICKS);
do {
signals = Wait(globalsignalset);
if (signals & WINDOWSIGNAL)
{
while ( (message = (struct IntuiMessage *)
GetMsg(wG->UserPort) ))
{
class = message->Class;
code = message->Code;
MouseX = message->MouseX;
MouseY = message->MouseY;
ReplyMsg((struct Message *)message);
if (!done2)
{
if ((class == MOUSEBUTTONS)&&(code == SELECTUP))
{ /* now try and make the move */
done2 = 1;
if ((MouseX > (COLH+SQUAREWIDTH)) || (MouseX < COLA) ||
(MouseY < ROW8) || (MouseY > (ROW1+BOBHEIGHT)))
{ /* Put the Piece Back */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
tmp1 = lastpiece;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
LoadBobImage(tmp1);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
AddBob(TheBob,rpG);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
else
{
done = 1; /* try the move */
if (MouseX < COLB)
DestCol = 0;
else if (MouseX < COLC)
DestCol = 1;
else if (MouseX < COLD)
DestCol = 2;
else if (MouseX < COLE)
DestCol = 3;
else if (MouseX < COLF)
DestCol = 4;
else if (MouseX < COLG)
DestCol = 5;
else if (MouseX < COLH)
DestCol = 6;
else
DestCol = 7;
if (MouseY < ROW7)
DestRow = 7;
else if (MouseY < ROW6)
DestRow = 6;
else if (MouseY < ROW5)
DestRow = 5;
else if (MouseY < ROW4)
DestRow = 4;
else if (MouseY < ROW3)
DestRow = 3;
else if (MouseY < ROW2)
DestRow = 2;
else if (MouseY < ROW1)
DestRow = 1;
else
DestRow = 0;
if ((DestRow == OrigRow) && (DestCol == OrigCol))
{
done = 0;
tmp1 = lastpiece;
LoadBobImage(BLANKDATA);
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
SortGList(rpG);
DrawGList(rpG,vP);
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
LoadBobImage(tmp1);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
AddBob(TheBob,rpG);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
else
{
MouseDropped = 1;
if (((piece == 'p')&&(DestRow == 7))||/* possible prom wht */
((piece == 'P')&&(!DestRow))) /* possible blk promotion */
{
PromoteChar = DisplayPromoteRequestor();
}
tempstr[4] = 0;
tempstr[0] = OrigCol + 'a';
tempstr[1] = OrigRow + '1';
tempstr[2] = DestCol + 'a';
tempstr[3] = DestRow + '1';
mySetABPenDrMd(rpG,1,bpen,JAM1);
Move(rpG,520,USERBOX+6);
if (computer != black)
sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
else
sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
Text(rpG,mvnstr,strlen(mvnstr));
Text(rpG,tempstr,strlen(tempstr));
}
}
}
else if (class == INTUITICKS)
{
BobVSprite->X = MouseX - 24;
BobVSprite->Y = MouseY - 16;
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
} /* ! done2 */
}
} /* signals & WINDOWSIGNAL */
} while (!done2);
ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags);
while ( (message = (struct IntuiMessage *)
GetMsg(wG->UserPort) ))
{
ReplyMsg((struct Message *)message);
}
}
}
}
} /* while message */
} /* signals & windowsignal */
} while (!done);
OffMenu(wG,SHOWMENUNUM);
OffMenu(wG,BOOKMENUNUM);
OffMenu(wG,SUPERMENUNUM);
OffMenu(wG,THINKMENUNUM);
if (tempstr[2] == '-')
{
for(ilen=2;ilen<strlen(tempstr);ilen++)
tempstr[ilen] = tempstr[ilen+1];
}
if (tempstr[4] == '/')
{
for(ilen=4;ilen<strlen(tempstr);ilen++)
tempstr[ilen] = tempstr[ilen+1];
}
if ((!PromoteChar)&&((strlen(tempstr) == 2) || (strlen(tempstr) == 4)))
{
r = tempstr[1] - '1';
if ((strlen(tempstr) == 2)&&(opponent == white))
{
r--;
}
else if ((strlen(tempstr) == 2)&&(opponent == black))
{
r++;
}
c = tempstr[0] - 'a';
l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
if ((color[l] == neutral)||(opponent != color[l]))
{
done2 = 1;
}
else if (color[l] == white)
piece = qxx[board[l]]; /* white are lower case pieces */
else
piece = pxx[board[l]]; /* black are upper case pieces */
if (strlen(tempstr) == 4)
{
r = tempstr[3] - '1';
}
else
{
if (opponent == white)
{
r++;
}
else
{
r--;
}
}
if (((piece == 'p')&&(r == 7))||/* possible prom wht */
((piece == 'P')&&(!r))) /* possible blk promotion */
{
PromoteChar = DisplayPromoteRequestor();
if (strlen(tempstr) == 2)
{
if (!r)
{
tempstr[4] = 0;
tempstr[3] = tempstr[1];
tempstr[2] = tempstr[0];
tempstr[1]++;
}
else
{
tempstr[4] = 0;
tempstr[3] = tempstr[1];
tempstr[2] = tempstr[0];
tempstr[1]--;
}
}
}
}
if (PromoteChar)
{
ilen = strlen(tempstr);
tempstr[ilen] = PromoteChar;
tempstr[ilen+1] = 0;
}
strcpy(str,tempstr);
if (!(stricmp(str,"new")))
{
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
WaitTOF();
RethinkDisplay();
}
}
void AnimateAmigaMove(str,piece)
char *str;
char piece; /* black are upper case pieces, white lower case */
{
int side;
int tmp1,tmp2;
int srow,scol,erow,ecol,incrx,incry,i;
long mpiece;
mpiece = piece;
if (!MouseDropped)
{
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
scol = str[0] - 'a';
srow = str[1] - '1';
ecol = str[2] - 'a';
erow = str[3] - '1';
tmp1 = srow & 1;
tmp2 = scol & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
tmp1 = erow & 1;
tmp2 = ecol & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[ecol],
RowArray[erow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[ecol],
RowArray[erow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
BobVSprite->X = ColArray[scol];
BobVSprite->Y = RowArray[srow];
LoadBobImage(mpiece);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
incry = (RowArray[erow] - RowArray[srow])/8;
incrx = (ColArray[ecol] - ColArray[scol])/8;
for(i=0;i<8;i++)
{
BobVSprite->X += incrx;
BobVSprite->Y += incry;
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
BobVSprite->X = WIDTH-1-BOBWIDTH;
BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
LoadBobImage(BLANKDATA);
AddBob(TheBob,rpG);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
if (piece >= 'a')
{
mpiece = 'r';
srow = 0;
erow = 0;
side = white;
if (str[2] == 'g') /* king side white */
{
scol = 7;
ecol = 5;
}
else
{
ecol = 3;
scol = 0;
}
}
else
{
mpiece = 'R';
srow = 7;
erow = 7;
side = black;
if (str[2] == 'g') /* king side black */
{
scol = 7;
ecol = 5;
}
else
{
ecol = 3;
scol = 0;
}
}
if (Castled[side])
{
Castled[side] = 0;
tmp1 = srow & 1;
tmp2 = scol & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
BobVSprite->X = ColArray[scol];
BobVSprite->Y = RowArray[srow];
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
LoadBobImage(mpiece);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
incry = (RowArray[erow] - RowArray[srow])/8;
incrx = (ColArray[ecol] - ColArray[scol])/8;
for(i=0;i<8;i++)
{
BobVSprite->X += incrx;
BobVSprite->Y += incry;
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
RemIBob(TheBob,rpG,vP);
SortGList(rpG);
DrawGList(rpG,vP);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
ClipBlitTrans (
&(BobTransImage->ti_RP), /* Source RastPort */
0, 0, /* Source LeftEdge, TopEdge */
rpG, /* Destination RastPort */
ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
BobTransImage->ti_IM->Width, /* Width of Image */
BobTransImage->ti_IM->Height,/* Height of Image */
BobTransImage->ti_sRP); /* Shadow RastPort */
LoadBobImage(BLANKDATA);
AddBob(TheBob,rpG);
MakeVPort(GfxBase->ActiView,vP);
MrgCop(GfxBase->ActiView);
}
else /* check EnPassant */
{
side ^= 1;
if (myEnPassant[side])
{
myEnPassant[side] = 0;
scol = str[2] - 'a';
if (str[3] == '3') /* white is removed from bd at 4*/
{
srow = 3;
}
else /* black is removed at pos 5 */
{
srow = 4;
}
tmp1 = srow & 1;
tmp2 = scol & 1;
if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
{
BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
else
{
BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
0xc0L,0xffL,0L);
}
}
}
}
}
#endif /* AMIGA */
void GetTimeString(str)
char *str;
{
#ifdef AMIGA
#endif
}
char __aligned *ColorStr[2];
char __far __aligned *CP[CPSIZE];
/*
* In a networked enviroment gnuchess might be compiled on different hosts
* with different random number generators, that is not acceptable if they
* are going to share the same transposition table.
*/
unsigned int
urand (void)
{
next *= 1103515245;
next += 12345;
return ((unsigned int) (next >> 16) & 0xFFFF);
}
unsigned long __aligned hashkey, hashbd;
#ifdef LONGINTS2
struct hashval __far hashcode[2][7][64];
#else
struct hashval __aligned hashcode[2][7][64];
#endif
#ifdef CACHE
#ifdef ttblsz
struct hashentry huge __aligned *ttable[2];
unsigned int __aligned ttblsize;
#endif
#else
#ifdef ttblsz
struct hashentry __aligned __far ttable[2][vttblsz + MAXrehash];
unsigned int __aligned ttblsize;
#endif
#endif
char __far __aligned savefile[128] = "";
char __far __aligned listfile[128] = "";
#ifdef HISTORY
unsigned char __far __aligned history[32768];
#endif
INTSIZE __aligned rpthash[2][256];
struct leaf __far __aligned Tree[TREE];
struct leaf __aligned *root;
INTSIZE __aligned TrPnt[MAXDEPTH];
INTSIZE __aligned PieceList[2][64], PawnCnt[2][8];
INTSIZE __aligned castld[2], Mvboard[64];
INTSIZE __aligned svalue[64];
struct flags __aligned flag;
INTSIZE __aligned opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither, INCscore;
long __aligned ResponseTime, ExtraTime, MaxResponseTime, et, et0, time0, ft;
long __aligned GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol,
THashCol, filesz;
long __aligned replus, reminus;
INTSIZE __aligned HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
INTSIZE __aligned player, xwndw, rehash;
struct GameRec __aligned GameList[MAXMOVES + MAXDEPTH];
INTSIZE __aligned Sdepth, GameCnt, Game50, MaxSearchDepth;
INTSIZE __aligned epsquare, contempt;
int __aligned Book;
struct TimeControlRec __aligned TimeControl;
INTSIZE __aligned TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
INTSIZE __aligned XCmoves[3], XCminutes[3], XCseconds[3], XC, XCmore;
const INTSIZE __aligned otherside[3] =
{black, white, neutral};
unsigned INTSIZE __aligned hint;
INTSIZE int __aligned TOflag; /* force search re-init if we backup search */
INTSIZE __aligned mtl[2], pmtl[2], hung[2];
INTSIZE __aligned Pindex[64];
INTSIZE __aligned PieceCnt[2];
INTSIZE __aligned FROMsquare, TOsquare;
INTSIZE __aligned HasKnight[2], HasBishop[2], HasRook[2], HasQueen[2];
INTSIZE __aligned ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], PawnThreat[MAXDEPTH];
INTSIZE __aligned Pscore[MAXDEPTH], Tscore[MAXDEPTH];
const INTSIZE __aligned qrook[3] =
{0, 56, 0};
const INTSIZE __aligned krook[3] =
{7, 63, 0};
const INTSIZE __aligned kingP[3] =
{4, 60, 0};
const INTSIZE __aligned rank7[3] =
{6, 1, 0};
const INTSIZE __aligned sweep[8] =
{false, false, false, true, true, true, false, false};
unsigned INTSIZE __aligned killr0[MAXDEPTH], killr1[MAXDEPTH];
unsigned INTSIZE __aligned killr2[MAXDEPTH], killr3[MAXDEPTH];
unsigned INTSIZE __aligned PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4, sidebit;
#ifdef KILLT
INTSIZE __far __aligned killt[0x4000];
#endif
const INTSIZE __aligned value[7] =
{0, valueP, valueN, valueB, valueR, valueQ, valueK};
const INTSIZE __aligned control[7] =
{0, ctlP, ctlN, ctlB, ctlR, ctlQ, ctlK};
INTSIZE __aligned stage, stage2, Developed[2];
FILE __aligned *hashfile;
unsigned int __aligned starttime;
INTSIZE int __aligned ahead = true, hash = true;
#if defined CHESSTOOL || defined XBOARD
void
TerminateChess (int sig)
{
ExitChess();
}
#endif
int __aligned timeopp[MINGAMEIN], timecomp[MINGAMEIN];
int __aligned compptr, oppptr;
inline void
TimeCalc ()
{
/* adjust number of moves remaining in gamein games */
int increment = 0;
int topsum = 0;
int tcompsum = 0;
int me,him;
int i;
/* dont do anything til you have enough numbers */
if (GameCnt < (MINGAMEIN * 2)) return;
/* calculate average time in sec for last MINGAMEIN moves */
for (i = 0; i < MINGAMEIN; i++)
{
tcompsum += timecomp[i];
topsum += timeopp[i];
}
topsum /= (100 * MINGAMEIN);
tcompsum /= (100 * MINGAMEIN);
/* if I have less time than opponent add another move */
me = TimeControl.clock[computer]/100;
him = TimeControl.clock[opponent]/100;
if(me < him) increment += 2;
/* if I am losing more time with each move add another */
/*if ( !((me - him) > 60) && tcompsum > topsum) increment++;*/
if ( tcompsum > topsum) increment +=2;
/* but dont let moves go below MINMOVES */
else if (TimeControl.moves[computer] < MINMOVES && !increment) increment++;
/* if I am doing really well use more time per move */
else if (me > him && tcompsum < topsum) increment = -1;
TimeControl.moves[computer] += increment;
}
/* hmm.... shouldn`t main be moved to the interface routines */
int
main (int aargc, char **aargv)
{
char cstring[40];
char *xwin = 0;
char *Lang = NULL;
#ifdef AMIGA
int tmpargcnt;
struct WBStartup *startmsg;
struct ExecBase **execbaseptr=(struct ExecBase **)4L;
UWORD cpuid;
struct ExecBase *execbase;
BPTR fp;
APTR tempxx;
struct WBArg *mywbptr;
struct DiskObject *dob;
execbase = *execbaseptr;
cpuid = execbase->AttnFlags;
if (!(cpuid & AFF_68020))
{
exit(0);
}
gfxversion = GfxBase->LibNode.lib_Version;
if (gfxversion < 37)
exit(-1);
if (!aargc)
{
startmsg = (struct WBStartup *)aargv;
mywbptr = startmsg->sm_ArgList;
if (dob = GetDiskObject (mywbptr->wa_Name))
{
xwin = FindToolType(dob->do_ToolTypes,"PRI");
if (xwin)
{
procpri = xwin[0] - '0';
if (procpri < 0)
procpri = 0;
if (procpri > 4)
procpri = 4;
}
xwin = FindToolType(dob->do_ToolTypes,"COLORS");
if (xwin)
{
if ((xwin[0] == '1')&&(xwin[1] == '6'))
gfxversion = 37;
else if ((xwin[0] == '6')&&(xwin[1] == '4'))
FasterDisplay = 1;
}
xwin = FindToolType(dob->do_ToolTypes,"MONITOR");
if (xwin)
{
if ((xwin[0] == '1')&&(xwin[1] == '5'))
v15Khz = 1;
}
xwin = FindToolType(dob->do_ToolTypes,"FASTAGA");
if (xwin)
{
if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
FasterDisplay = 1;
}
xwin = FindToolType(dob->do_ToolTypes,"SUPER72");
if (xwin)
{
if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
Super72 = 1;
}
FreeDiskObject (dob);
}
xwin = 0L;
}
else if (aargc > 1)
{
for(tmpargcnt=1;tmpargcnt<aargc;tmpargcnt++)
{
if (!(strcmp(aargv[tmpargcnt],"16")))
{
gfxversion = 37;
}
else if (!(stricmp(aargv[tmpargcnt],"Super72")))
{
Super72 = 1;
}
else if (!(stricmp(aargv[tmpargcnt],"15KHZ")))
{
v15Khz = 1;
}
else if ((!(stricmp(aargv[tmpargcnt],"FASTAGA")))||((!(strcmp(aargv[tmpargcnt],"64")))))
{
FasterDisplay = 1;
}
else if (strcmp(aargv[tmpargcnt],"256"))
{
procpri=atoi(aargv[tmpargcnt]);
if (procpri < 0)
procpri = 0;
if (procpri > 4)
procpri = 4;
}
}
}
if (gfxversion < 39)
Super72 = 0;
Delay(3L);
myproc = (struct Process *)FindTask(0L);
tempxx = myproc->pr_WindowPtr;
Delay(3L);
myproc->pr_WindowPtr = (APTR)-1L;
if (!(fp = Open("uchess:uchess.lang",MODE_OLDFILE)))
{
system("Assign >nil: uchess: \"\"");
}
else
Close(fp);
myproc->pr_WindowPtr = tempxx;
#endif
gsrand (starttime = ((unsigned int) time ((long *) 0))); /* init urand */
#ifdef ttblsz
ttblsize = ttblsz;
rehash = -1;
#endif /* ttblsz */
flag.easy = 0;
#ifndef AMIGA
if (argc > 2)
{
if (argv[1][0] == '-' && argv[1][1] == 'L')
{
Lang = argv[2];
argv += 2;
argc -= 2;
}
}
#endif
InitConst (Lang);
ColorStr[0] = CP[118];
ColorStr[1] = CP[119];
#ifndef AMIGA
while (argc > 1 && ((argv[1][0] == '-') || (argv[1][0] == '+')))
{
switch (argv[1][1])
{
case 'a':
ahead = ((argv[1][0] == '-') ? false : true);
break;
case 'h':
hash = ((argv[1][0] == '-') ? false : true);
break;
case 's':
argc--;
argv++;
if (argc > 1)
strcpy (savefile, argv[1]);
break;
case 'l':
argc--;
argv++;
if (argc > 1)
strcpy (listfile, argv[1]);
break;
#if ttblsz
case 'r':
if (argc > 2)
rehash = atoi (argv[2]);
argc--;
argv++;
if (rehash > MAXrehash)
rehash = MAXrehash;
break;
case 'T':
if (argc > 2)
ttblsize = atoi (argv[2]);
argc--;
argv++;
if (ttblsize > 0 && ttblsize < 24)
ttblsize = (1 << ttblsize);
else
ttblsize = ttblsz;
break;
#ifdef HASHFILE
case 't': /* create or test persistent transposition
* table */
hashfile = fopen (HASHFILE, RWA_ACC);
if (hashfile)
{
fseek (hashfile, 0L, SEEK_END);
filesz = (ftell (hashfile) / sizeof (struct fileentry)) - 1;
}
if (hashfile != NULL)
{
long i, j;
int nr[MAXDEPTH];
struct fileentry n;
/*ShowMessage (CP[49]);*/
for (i = 0; i < MAXDEPTH; i++)
nr[i] = 0;
fseek (hashfile, 0L, SEEK_END);
i = ftell (hashfile) / sizeof (struct fileentry);
fseek (hashfile, 0L, SEEK_SET);
for (j = 0; j < i + 1; j++)
{
fread (&n, sizeof (struct fileentry), 1, hashfile);
if (n.depth)
{
nr[n.depth]++;
nr[0]++;
}
}
sprintf (astr,CP[109],
nr[0], i);
/*ShowMessage(astr);*/
for (j = 1; j < MAXDEPTH; j++)
/*
printf ("%d ", nr[j]);
printf ("\n")*/;
}
return 0;
case 'c': /* create or test persistent transposition
* table */
if (argc > 2)
filesz = atoi (argv[2]);
if (filesz > 0 && filesz < 24)
filesz = (1 << filesz) - 1 + MAXrehash;
else
filesz = Deffilesz + MAXrehash;
if ((hashfile = fopen (HASHFILE, RWA_ACC)) == NULL)
hashfile = fopen (HASHFILE, WA_ACC);
if (hashfile != NULL)
{
long j;
struct fileentry n;
/*printf (CP[66]);*/
for (j = 0; j < 32; j++)
n.bd[j] = 0;
n.f = n.t = 0;
n.flags = 0;
n.depth = 0;
n.sh = n.sl = 0;
for (j = 0; j < filesz + 1; j++)
fwrite (&n, sizeof (struct fileentry), 1, hashfile);
fclose (hashfile);
}
/* else
printf (CP[50], HASHFILE);*/
return (0);
#endif /* HASHFILE */
#endif /* ttblsz */
case 'x':
xwin = &argv[1][2];
break;
case 'v':
/* fprintf (stderr, CP[102], version, patchlevel);*/
exit (1);
default:
/*fprintf (stderr, CP[113]);*/
exit (1);
}
argv++;
argc--;
}
#endif
XC = 0;
MaxResponseTime = 0;
#if defined CHESSTOOL || defined XBOARD
signal (SIGTERM, TerminateChess);
TCflag = true;
TCmoves = 40;
TCminutes = 120;
TCseconds = 0;
TCadd = 0;
OperatorTime = 0;
#else
/* TCflag = false;*/
/* OperatorTime = 0;*/
TCflag = true;
TCmoves = 60;
TCminutes = 10;
TCseconds = 0;
OperatorTime = 0;
#endif
#ifndef AMIGA
if (argc == 2)
{
char *p;
MaxResponseTime = 100L*strtol(argv[1], &p, 10);
if (*p == ':')
MaxResponseTime = 60L*MaxResponseTime +
100L*strtol(++p, (char **) NULL, 10);
TCflag = false;
TCmoves = 0;
TCminutes = 0;
TCseconds = 0;
}
if (argc >= 3)
{
char *p;
if (argc > 9)
{
/* printf ("%s\n", CP[220]);*/
exit (1);
}
TCmoves = atoi (argv[1]);
TCminutes = strtol (argv[2], &p, 10);
if (*p == ':')
TCseconds = strtol (p + 1, (char **) NULL, 10);
else
TCseconds = 0;
TCflag = true;
argc -= 3;
argv += 3;
while (argc > 1)
{
XCmoves[XC] = atoi (argv[0]);
XCminutes[XC] = strtol (argv[1], &p, 10);
if (*p == ':')
XCseconds[XC] = strtol (p + 1, (char **) NULL, 10);
else
XCseconds[XC] = 0;
if (XCmoves[XC] && (XCminutes[XC] || XCseconds[XC]))
XC++;
else
{
/*printf (CP[220]);*/
exit (1);
}
argc -= 2;
argv += 2;
}
if (argc)
{
/*printf ("%s\n", CP[220]);*/
exit (1);
}
}
#endif /* AMIGA */
#ifdef AMIGA
if (!AmigaStartup())
{
exit(2);
}
#endif
Initialize ();
#ifndef CACHE
#ifdef ttblsz
Initialize_ttable ();
#endif /* ttblsz */
#endif
Initialize_dist ();
Initialize_moves ();
FirstTime = 1;
NewGame ();
flag.easy = ahead;
flag.hash = hash;
if (xwin)
xwndw = atoi (xwin);
hashfile = NULL;
#if ttblsz
#ifdef HASHFILE
hashfile = fopen (HASHFILE, RWA_ACC);
if (hashfile)
{
fseek (hashfile, 0L, SEEK_END);
filesz = ftell (hashfile) / sizeof (struct fileentry) - 1;
}
#if !defined CHESSTOOL && !defined XBOARD
else
ShowMessage (CP[98]);
#endif
#endif /* HASHFILE */
#endif /* ttblsz */
#ifdef AMIGA
(void)SetTaskPri((struct Task *)myproc,procpri);
Delay(3L);
SetMenuStrip(wG,&MenuList1); /* attach any Menu */
MenuStripSet = 1;
#endif
while (!(flag.quit))
{
oppptr = (oppptr + 1) % MINGAMEIN;
if (flag.bothsides && !flag.mate)
{
SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
SelectMove (opponent, 1);
}
else
{
InputCommand (cstring);
}
if (opponent == black)
if (flag.gamein || TCadd)
{
TimeCalc ();
}
else if (TimeControl.moves[opponent] == 0)
{
if (XC)
if (XCmore < XC)
{
TCmoves = XCmoves[XCmore];
TCminutes = XCminutes[XCmore];
TCseconds = XCseconds[XCmore];
XCmore++;
}
SetTimeControl ();
}
compptr = (compptr + 1) % MINGAMEIN;
if (SupervisorMode)
{
computer = computer ^ 1;
opponent = opponent ^ 1;
xwndw = (computer == white) ? WXWNDW : BXWNDW;
flag.force = false;
Sdepth = 0;
}
else if (!(flag.quit || flag.mate || flag.force))
{
SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
SelectMove (computer, 1);
if (computer == black)
if (flag.gamein)
{
TimeCalc ();
}
else if (TimeControl.moves[computer] == 0)
{
if (XC)
if (XCmore < XC)
{
TCmoves = XCmoves[XCmore];
TCminutes = XCminutes[XCmore];
TCseconds = XCseconds[XCmore];
XCmore++;
}
SetTimeControl ();
}
}
if ((flag.mate)&&(!Mate)&&(!DrawnGame))
ShowMessage("CheckMate");
if (Mate)
{
ShowMessage(MateString);
}
else if (DrawnGame)
{
ShowMessage("Draw..");
}
else if ((!flag.mate)&&(PlayMode == 2)&&(!ResignOffered)&&(!flag.quit))
{
if (global_tmp_score < -950)
{
if (DoResign())
{
flag.mate = true;
Mate = 1;
ShowMessage("You Win!");
ShowMessage("UChess Resigns");
}
}
}
}
#if ttblsz
#ifdef HASHFILE
if (hashfile)
fclose (hashfile);
#endif /* HASHFILE */
#endif /* ttblsz */
ExitChess ();
}